Python接口自动化测试和性能测试

supervisor守护进程虚拟环境部署Django

2019-05-27  本文已影响29人  梨花菜

1.安装supervisor

sudo yum install supervisor

2.编辑配置文件

# 先备份
cp /etc/supervisord.conf /etc/supervisord.conf_bak
# 编辑
vim /etc/supervisord.conf
# command 是执行的命令,由于python环境在虚拟环境中,需要指定完全路径
# directory 项目目录
# 下面是停止命令时杀死进程.如果不填写,可能会导致手动停止后,启动program错误
# stopasgroup=true
# stopsignal=QUIT
[program:django]
command=/home/faster/.virtualenvs/fasterenv/bin/python manage.py runserver 0.0.0.0:8000
directory=/home/faster/FasterRunner
stopasgroup=true
stopsignal=QUIT
user=faster
autostart=true
autorestart=true
stderr_logfile=/home/faster/err.log
stdout_logfile=/home/faster/out.log

3.启动 supervisord

sudo supervisord -c  /etc/supervisord.conf

4.常用命令

# 注意非root用户,需要加上sudo
# 重启supervisor
supervisorctl reload
# 启动名字为django的program 
supervisorctl start django
# 停止名字为django的program 
supervisorctl stop django
# 查看名字为django的program 状态
supervisorctl status django
# 查看所有program的状态
supervisorctl status all
# 停止所有program
supervisorctl stop all

5.错误排查

解决unix:///tmp/supervisor.sock no such file的问题1
解决unix:///tmp/supervisor.sock no such file的问题2
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting

解决方法:
find / -name supervisor.sock
unlink /name/supervisor.sock
unix:///var/run/supervisor.sock no such file
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart

Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
unlink /var/run/supervisor/supervisor.sock

上一篇 下一篇

猜你喜欢

热点阅读