用supervisord管理uwsgi
1. ~$: sudo easy_install supervisor
2. ~$: echo_supervisord_conf > supervisord.conf
3. ~$: vim supervisord.conf
4. ~$: sudo cp /usr/local/bin/uwsgi /usr/local/sbin/uwsgi
5. 末尾添加:
[program:myapp]
command=/usr/local/sbin/uwsgi -s 127.0.0.1:11000 -M -R 200 -p 2 --env "DJANGO_SETTINGS_MODULE=settings" -w "django.core.handlers.wsgi:WSGIHandler()"
directory=/home/kevin/workspace/myapp ; 指定执行命令的路径
user=kevin ; 如果supervisord是通过root启动的,则user指定command运行的用户;否则此项配置不起作用
autostart=true ; 随supervisord的启动而启动
autorestart=true ; 意外情况自动重启
stdout_logfile=/home/kevin/log/myapp/uwsgi.log ; 程序运行中日志保存的文件路径
redirect_stderr=true ; 标准程序错误自动发送到supervisord
stopsignal=QUIT ; 退出信号
notice:
1. nginx和uwsgi已经实现互通
2. /home/kevin/workspace/myapp为django项目目录
other:
;[inet_http_server] ; inet (TCP) server disabled by default
;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
;username=user ; (default is no username (open server))
;password=123
将每行前面的封号(注释)取消,可以在浏览器中访问127.0.0.1:9001;username=user;password=123登录界面控制平台
分享两个链接:
http://luchanghong.com/server/2012/09/10/use-supervisor-as-daemonize-of-uwsgi.html
http://luchanghong.com/server/2012/09/11/some-errors-when-restart-supervisor-with-uwsgi.html