内容简介:github项目地址:克隆项目:git clone进入项目:cd supervisor
一、 golang、beego等环境安装与配置
二、supervisor安装
github项目地址: https://github.com/Supervisor/supervisor
克隆项目:git clone https://github.com/Supervisor/supervisor.git
进入项目:cd supervisor
安装执行:python setup.py install
三、supervisor配置文件
vi /etc/supervisord.conf
[supervisord]
http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001 ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700 ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022 ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.log ; (supervisor输出日志,main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
;http_username=user ; (default is no username (open system))
;http_password=123 ; (default is no password (open system))
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;user=chrism ; (default is current user, required if root)
;directory=/tmp ; (default is not to cd during start)
;environment=KEY=value ; (key value pairs to add to environment)
[supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
[unix_http_server]
file=/var/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0777 ; socket file mode (default 0700)
;chown=root:root ; socket file uid:gid owner
;username=root ; (default is no username (open server))
;password=root ; (default is no password (open server))
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:hello] ;可以在这边配置要管理的程序
directory=/home/www/php/ ;
command=/usr/bin/php test.php ;
process_name=%(program_name)s ;
numprocs=1 ;
autostart=true ;
startsecs=1 ;
autorestart=true ;
startretries=3 ;
user=root ;
redirect_stderr=true ;
stdout_logfile_maxbytes=20MB ;
stdout_logfile_backups=10 ;
[include] ;也可以通过include包含进来程序配置文件
files = ./supervisor/conf.d/*.ini ;
vi /etc/supervisor/conf.d/wx-prj.ini
[program:wx-prj] ;directory=/home/www/go/src/wx-prj ;go项目目录 ;command=/home/www/go/src/wx-prj/wx-prj ;go项目编译好的可执行文件 directory=/home/www/go/bin ; command=/home/www/go/bin/wx-prj ; process_name=%(program_name)s ; numprocs=1 ; autostart=true ; startsecs=1 ; autorestart=true ; startretries=3 ; user=root ; redirect_stderr=true ; stdout_logfile=/home/www/go/wx-prj.stdout.log ;打印标准输出日志 stdout_logfile_maxbytes=20MB ; stdout_logfile_backups=10 ; stderr_logfile=/home/www/go/wx-prj.stderr.log ;打印标准错误输出日志 stderr_logfile_maxbytes=20MB ; stderr_logfile_backups=10 ; log_stdout=true ; if true, log program stdout (default true) log_stderr=true ; if true, log program stderr (def false)
四、启动supervisor服务
supervisord -c /etc/supervisord.conf
启动服务时可以跟踪日志输出观察 [root@10-23-67-69 go]# tail -f /var/log/supervisor/supervisord.log 2018-10-26 13:36:30,881 INFO Included extra file "/etc/./supervisor/conf.d/wx-prj.ini" during parsing 2018-10-26 13:36:30,902 INFO RPC interface 'supervisor' initialized 2018-10-26 13:36:30,902 CRIT Server 'inet_http_server' running without any HTTP authentication checking 2018-10-26 13:36:31,203 INFO RPC interface 'supervisor' initialized 2018-10-26 13:36:31,203 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2018-10-26 13:36:31,206 INFO daemonizing the supervisord process 2018-10-26 13:36:31,207 INFO supervisord started with pid 17040 2018-10-26 13:36:32,209 INFO spawned: 'hello' with pid 17041 2018-10-26 13:36:32,213 INFO spawned: 'wx-prj' with pid 17042 2018-10-26 13:36:32,219 INFO spawned: 'world' with pid 17043 2018-10-26 13:36:33,279 INFO success: hello entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2018-10-26 13:36:33,279 INFO success: wx-prj entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2018-10-26 13:36:33,279 INFO success: world entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
也通过命令查看程序状态 [root@10-23-67-69 conf.d]# supervisorctl status hello RUNNING pid 17041, uptime 0:00:19 world RUNNING pid 17043, uptime 0:00:19 wx-prj RUNNING pid 17042, uptime 0:00:19
五、重载supervisor修改过的配置
supervisorctl reload
六、停止/启动/重启supervisor管理的程序
[root@10-23-67-69 conf.d]# supervisorctl stop wx-prj wx-prj: stopped [root@10-23-67-69 conf.d]# supervisorctl start wx-prj wx-prj: started [root@10-23-67-69 conf.d]# supervisorctl restart wx-prj wx-prj: stopped wx-prj: started [root@10-23-67-69 conf.d]# supervisorctl stop all hello: stopped wx-prj: stopped world: stopped [root@10-23-67-69 conf.d]# supervisorctl start all hello: started wx-prj: started world: started
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Domain-Driven Design Distilled
Vaughn Vernon / Addison-Wesley Professional / 2016-6-2 / USD 36.99
Domain-Driven Design (DDD) software modeling delivers powerful results in practice, not just in theory, which is why developers worldwide are rapidly moving to adopt it. Now, for the first time, there......一起来看看 《Domain-Driven Design Distilled》 这本书的介绍吧!
JSON 在线解析
在线 JSON 格式化工具
RGB转16进制工具
RGB HEX 互转工具