以什么方式运行进程?将它做成服务,再以"service xxx start/stop"方式运行。或者以"nohup xxx &"方式运行,需要停止时,先ps获得进程id,然后kill掉.有什么好点的办法?supervisor正好解决这个问题。安装sudo pip install supervisor创建配置文件echo_supervisord_conf > /etc/supervisord.conf取消注释打开/etc/supervisord.conf,取消下面两行注释,并修改files内容.[include]
files = /etc/supervisor/*.ini新建配置目录新建supervisor目录及test.ini文件➜ /etc tree supervisor
supervisor
└── test.ini配置内容test.init内容[program:test]
command=python -m SimpleHTTPServer 8000
directory=/home/wyq/运行运行后,在浏览器访问8000端口supervisord 调试运行,此时需要先将test.ini中directory注释掉.supervisord -dsupervisor也可指定配置文件 supervisord -c xxxx查看日志tail -f supervisord.conf查看运行状态➜ ~ supervisorctl status
test RUNNING pid 4922, uptime 0:00:07停止任务启动与重启参数为start/restart ➜ ~ supervisorctl stop test
test: stopped
➜ ~ supervisorctl status
test STOPPED Jul 09 04:32 PM停止pkill supervisord