centos7安装配置supervisor守护进程

yum install Supervisor 
supervisord -c /etc/supervisord.conf

进入 cd /etc 目录 找到supervisord.conf 配置文件 和 supervisord.d 文件夹,使用vim编辑supervisord.conf文件,它会加载supervisord.d文件夹中的所有.ini配置文件

[program:DeployLinux]   #DeployLinux  为程序的名称
command=dotnet DeployLinux.dll #需要执行的命令
directory=/home/publish #命令执行的目录
environment=ASPNETCORE__ENVIRONMENT=Production #环境变量   注释符不用# 环境变量可以省略
user=root #用户
stopsignal=INT 
autostart=true #是否自启动
autorestart=true #是否自动重启
startsecs=3 #自动重启时间间隔(s)
stderr_logfile=/var/log/ossoffical.err.log #错误日志文件
stdout_logfile=/var/log/ossoffical.out.log #输出日志文件
配置实例
[program:future_price_depth_new.py]
command=python /bot/mkr/future_price_depth_new.py 注意intergal_util.py用python3启动 [command=python3 /bot/mkr/future_price_depth_new.py]
directory=/bot/mkr/
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=3
stderr_logfile=/bot/log/future_price_depth_new.err.log
stdout_logfile=/bot/log/future_price_depth_new.out.log

supervisorctl reload  //重新加载配置文件

常用命令介绍

supervisorctl 是 supervisord的命令行客户端工具
supervisorctl status:查看所有进程的状态
supervisorctl stop es:停止es
supervisorctl start es:启动es
supervisorctl restart es: 重启es
supervisorctl update :配置文件修改后可以使用该命令加载新的配置
supervisorctl reload: 重新启动配置中的所有程序

    或者

supervisord   -c supervisor.conf                     通过配置文件启动supervisor
supervisorctl -c supervisor.conf status              查看状态
supervisorctl -c supervisor.conf reload              重新载入配置文件
supervisorctl -c supervisor.conf start [all]|[x]     启动所有/指定的程序进程
supervisorctl -c supervisor.conf stop [all]|[x]      关闭所有/指定的程序进程 
ps -ef|grep python
root       572     1  0 Dec15 ?        00:00:17 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root      7704  7686  1 16:13 pts/2    00:03:06 /root/anaconda3/bin/python3 future_price_depth_new_2.py
root      7726  7708  1 16:13 pts/3    00:03:08 /root/anaconda3/bin/python3 future_price_depth_new.py
root      8291     1  1 Dec06 ?        04:10:59 python future_price_depth_new.py
root      8298     1  1 Dec06 ?        04:06:28 python future_price_depth_new_2.py
root     16948     1  0 19:46 ?        00:00:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root     16949 16948  3 19:46 ?        00:00:00 python /bot/mkr/future_price_depth_new.py
root     16950 16948  7 19:46 ?        00:00:00 python /bot/mkr/timer_util.py
root     16951 16948  9 19:46 ?        00:00:01 python3 /bot/mkr/intergal_util.py
root     16952 16948  9 19:46 ?        00:00:01 python /bot/mkr/mkr.py
root     16953 16948  1 19:46 ?        00:00:00 python /bot/mkr/webs_util.py
root     16963 16952  8 19:46 ?        00:00:00 /root/anaconda3/bin/python /bot/mkr/mkr.py
root     16977 10161  0 19:46 pts/0    00:00:00 grep --color=auto python
root     19717     1  0 Dec15 ?        00:04:00 python -u w267bot.py -273195517 605518038:AAGy5TAoc4DfeW3Ol3ezEryqYEJGgq7mbF0
原文地址:https://www.cnblogs.com/shione/p/10857343.html