supervisor搭建及配置管理swoole服务
首页->学习资料->其它->开发环境搭建 关键词: 发布时间:2021-05-22 02:53:39 浏览次数:2054

安装:

apt-get install supervisor


启动:

service supervisor start

service supervisor stop


supervisorctl:

supervisorctl shutdown #关闭所有任务

supervisorctl stop|start program_name #启动或停止服务

supervisorctl status #查看所有任务状态

$supervisorctl reload #重新载入配置


配置示例文件(/etc/supervisor/conf.d/test.conf)

[program:taibao_]

process_name=listen-auto-call-mq-save-to-ftp

command=php /data/www/artisan taiBao:listen-auto-call-mq-save-to-ftp

autostart=true

autorestart=true

user=root#注意这里最好配置成root,不然执行netstat等命令可能报:Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it al

numprocs=1

redirect_stderr=true

stdout_logfile=/etc/supervisor/conf.d/supervisor.log


[program:taibao_]

process_name=shell-run-artisan

command=sh /data/www/crontab.sh

autostart=true

autorestart=true

user=root

numprocs=1

redirect_stderr=true

stdout_logfile=/etc/supervisor/conf.d/supervisor.log

startsecs=10

startretries=3


[program:taibao]

process_name=supervisor-artisan

command=php /data/www/artisan taiBao:supervisor-artisan

autostart=true

autorestart=true

user=root

numprocs=1

redirect_stderr=true

startsecs=10

startretries=3

stdout_logfile=/etc/supervisor/conf.d/supervisor.log




tip1:swoole的daemonize参数要设置为0,否则supervisor管理不到,supervisor停止后server还在跑

$serv->set(array(

            'worker_num' => 1,

            'daemonize' => 0,

            'backlog' => 128,

        ));


tip2:

supervisor官方文档:http://supervisord.org/configuration.html


tip3:日志定时备份脚本

#!/bin/bash

        logfile=/var/log/app.log

        if [ -s $logfile ];then

          rm -f $logfile

        fi

        touch $logfile

        chmod a+w $logfile


        _START () {

          echo "$(date +"%F %H:%M:%S") INOF Start collecting logs in file $logfile" >/proc/1/fd/1

          tail -F $logfile >/proc/1/fd/1 2>/dev/null &

        }

        while true

        do

          ps aux|grep "tail -F "|grep -v grep >/dev/null 2>&1

          if [ $? -ne 0 ];then

                echo "$(date +"%F %H:%M:%S") ERROR collection process is not running" >/proc/1/fd/2

                _START

          fi

          sleep 30

          if [ -s $logfile ];then

                 Size=$(stat -c "%s" $logfile)

                 if [ $Size -ge 110000000 ];then

                        echo "$(date +"%F %H:%M:%S") WAR clean file $logfile" >/proc/1/fd/2

                        >$logfile

                 fi

          else

                 echo "$(date +"%F %H:%M:%S") WAR log file $logfile is not found" >/proc/1/fd/2

          fi

        done


赞:(0)
踩:(0)
相关文章
windows下使用MongoDB Compass Com
Oracle VM VirtualBox中设置共享文
linux安装openvpn并保存密码
deepin v20深度系统安装docker及do
域名在阿里云服务器换成腾讯云后备
windows下安装VirtualBox增强工具
国内访问github慢或打不开的解决方
linux下安装phpstorm2018及激活码
vmware中虚拟机上不了网及共享文件
linux版phpstorm2020.3.3及激活码
热门文章
win7中将文件拷贝到虚拟机linux下
phpexcel设置行高及列宽,背景颜色,
rabbitmq无法启动
intellij idea不显示git push按钮
php7中使用mongodb的aggregate进行
laravel页面静态化的方法
centos7.4 64位下swoole安装及配置
navicate连接mycat报1184错误
curl设置超时不起作用(CURLOPT_TIM
devops-jenkins容器为pending状态
好评文章
phpexcel设置行高及列宽,背景颜色,
php7中使用mongodb的aggregate进行
intellij idea打开文件所在文件夹
windows下使用MongoDB Compass Com
win7中将文件拷贝到虚拟机linux下
laravel 中悲观锁 & 乐观锁的使用
单点登录sso原理及php实现方式及de
navicate连接mycat报1184错误
rabbitmq无法启动
laravel整合dingo/api方法步骤:jwt
标签
rabbitmq mysql备份 elasticsearch golang swoole
我的项目
【github】www.github.com/hurong241
【码云】gitee.com/hu_rong/projects
【docker hub】hub.docker.com/repositories/hurong241
【packagist】packagist.org/users/hurong241/packages
站点信息
建站时间:2011年
文章数:623篇
浏览数:1303109
粤ICP备18028092号-1  微信:hurong241