首先到github上下载supervisor源码。
https://github.com/Supervisor/supervisor
git clone https://github.com/Supervisor/supervisor
cd supervisor
然后 python3 setup.py install
安装完成后到我们的python安装目录下bin文件夹里
使用systemctl设置开机启动
vim /etc/systemd/system/supervisor.service
[Unit]
Description=supervisor
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/local/bin/supervisorctl shutdown all
ExecReload=/usr/local/bin/supervisorctl reload all
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
常用命令
supervisorctl stop program_name # 停止某一个进程,program_name 为 [program:x] 里的 x
supervisorctl start program_name # 启动某个进程
supervisorctl restart program_name # 重启某个进程
supervisorctl stop groupworker: # 结束所有属于名为 groupworker 这个分组的进程 (start,restart 同理)
supervisorctl stop groupworker:name1 # 结束 groupworker:name1 这个进程 (start,restart 同理)
supervisorctl stop all # 停止全部进程,注:start、restartUnlinking stale socket # /tmp/supervisor.sock
# 、stop 都不会载入最新的配置文件
supervisorctl reload # 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程
supervisorctl update # 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
感谢 https://blog.csdn.net/qq_34896760/article/details/80513206
torando 配置
[program:strategyManagement]
directory=/myProjectService/service/pool_admin_api
command=python3 /myServices/strategyManagement/run.py --port 81%(process_num)02d
process_name=%(program_name)s_%(process_num)02d
user=moxiao
startsecs=0
stopwaitsecs=0
redirect_stderr=true
stdout_logfile=/myServices/logs/strategyManagement/t1.log
numprocs=4
numprocs_start=1