代码改变世界

supervisor(进程守护程序)

2016-11-25 09:20  Miles.Yao  阅读(1372)  评论(0编辑  收藏  举报

运行环境:

Linux 系统

 

安装:

sudo apt-get install supervisor

 

启动,停止,重启,重置,查看进程状态:

sudo service supervisor start

sudo service supervisor stop

sudo service supervisor restart

sudo service supervisor reload

sudo supervisorctl status

 

配置:

1. 首先在/etc/supervisor/conf.d 路径下面创建以.conf为后辍

2. 配置例子如下:

[group:wip] # 进程组
prorams=wip-8000, wip-8001 # 子进程序列

[program:wip-8000]
command=python3.4 /home/myao/oschina/wip/main.py --port=8000 runserver # 命令
directory=/home/myao/oschina/wip # 目录
user=www-data # 开启进程的用户
autorestart=true #  如果进程挂了,是否自动重启
redirect_stderr=true
stdout_logfile=/var/log/wip.log # 日志文件
loglevel=info
environment=PATH="/home/myao/oschina/wip/env/bin/" # 程序运行环境,该配置可以解决python独立环境的问题

[program:wip-8001]
command=python3.4 /home/myao/oschina/wip/main.py --port=8001 runserver
directory=/home/myao/oschina/wip
user=www-data
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/wip.log
loglevel=info
environment=PATH="/home/myao/oschina/wip/env/bin/"