supervisor使用

一切测试在centos7下

安装

yum install -y supervisor

配置

/etc/supervisor.conf

unix_http_server用于让ctl连接,可以给ctl连接设定用户和密码

可以开启一个inet_http_server,用于web管理,不过使用ctl更安全一些。

1; Sample supervisor config file. 2 3[unix_http_server] 4file=/var/run/supervisor/supervisor.sock ; (the path to the socket file) 5;chmod=0700 ; sockef file mode (default 0700) 6chown=svisor:nogroup ; socket file uid:gid owner 7username=user ; (default is no username (open server)) 8password=123 ; (default is no password (open server)) 9 10[inet_http_server] ; inet (TCP) server disabled by default 11port=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface) 12username=user ; (default is no username (open server)) 13password=123 ; (default is no password (open server))

启动

supervisord -c /etc/supervisor.conf

创建进程管理文件

在主配置文件里有include参数,可以把按应用分的ini配置文件包含进去

1; [program:xx]是被管理的进程配置参数,xx是进程的名称 2[program:xx] 3command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run ; 程序启动命令 4autostart=true ; 在supervisord启动的时候也自动启动 5startsecs=10 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为16autorestart=true ; 程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启 7startretries=3 ; 启动失败自动重试次数,默认是3 8user=tomcat ; 用哪个用户启动进程,默认是root 9priority=999 ; 进程启动优先级,默认999,值小的优先启动 10redirect_stderr=true ; 把stderr重定向到stdout,默认false 11stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MB 12stdout_logfile_backups = 20 ; stdout 日志文件备份数,默认是10 13; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件) 14stdout_logfile=/opt/apache-tomcat-8.0.35/logs/catalina.out 15stopasgroup=false ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程 16killasgroup=false ;默认为false,向进程组发送kill信号,包括子进程

加载新配置

添加新的ini后,需要让配置生效

使用supervisorctl工具

1supervisor> reload 2Really restart the remote supervisord process y/N? n 3supervisor> update 4#reload是重启supervisord 5#update是更新配置

开机启动

使用systemctl服务,让supervisord开机自启动,它会自动去使用/etc/supervisor.conf。这样,所有被supervisor管理的ini,都会被托管。

只要在设置里autostart=true,这样就会一起被启动。

一个django的实例

由于使用venv,所以command里要使用对应环境的uwsgi命令

1[program:mofang_wsgi] 2directory=/data/mofangsvr/ 3command=/data/mofangsvr/venv/bin/uwsgi --ini mofang.ini 4stdout_logfile=/data/mofangsvr/stdout.out 5autostart=true 6autorestart=true 7startsecs=5 8priority=1 9stopasgroup=true 10killasgroup=true

要注意的是,uwsgi的ini文件里,守护进程必须注释掉,suipervisord不支持守护进程启动

1# 以守护进程方式提供服, 输出信息将会打印到log中 2#daemonize = wsgi.log

一个nginx的实例

要特意关掉守护进程

1[program:mofang_nginx] 2directory=/data/nginx/ 3command=/data/nginx/sbin/nginx -g 'daemon off;' 4stdout_logfile=/data/nginx/std.out 5autostart=true 6autorestart=true 7startsecs=5 8priority=1 9stopasgroup=true 10killasgroup=true
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )