玩蛇网提供最新Python编程技术信息以及Python资源下载!

用nginx+uwsgi+python+flask/django部署3个web,使用supervisor监控管理uwsg

site1,site2和site3使用各自的virtualenv环境运行,site1为django app,site2与site3同为flask app且配置基本相同,最终结果是site1和site2运行正常,site3不正常,检查supervisor日志应该是site3的uwsgi进程起不来,不知道为什么,花了一个晚上了还是找不出问原因,谁有空帮忙看下,感谢

supervisor的日志如下

2013-04-24 22:36:47,316 INFO success: site1 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2013-04-24 22:36:47,316 INFO success: site2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2013-04-24 22:36:47,317 INFO spawned: 'site3' with pid 14559
2013-04-24 22:36:47,327 INFO exited: site3 (exit status 1; not expected)
2013-04-24 22:36:49,331 INFO spawned: 'site3' with pid 14564
2013-04-24 22:36:49,339 INFO exited: site3 (exit status 1; not expected)
2013-04-24 22:36:52,343 INFO spawned: 'site3' with pid 14566
2013-04-24 22:36:52,351 INFO exited: site3 (exit status 1; not expected)
2013-04-24 22:36:53,352 INFO gave up: site3 entered FATAL state, too many start retries too quickly

site3的uwsgi日志如下

unable to load configuration from 666
unable to load configuration from 666
unable to load configuration from 666
unable to load configuration from 666

site3 nginx配置

server {
    listen 80;
    server_name site3.site2.com;
    access_log /var/log/nginx/site3.site2.com.access.log;
    error_log /var/log/nginx/site3.site2.com.error.log;
    location /
    {
        include uwsgi_params;
        uwsgi_pass unix:///tmp/uwsgi_site3.sock;
    }
    location ~ /\.    { access_log off; log_not_found off; deny all; }
    location ~ ~$     { access_log off; log_not_found off; deny all; }
}

site2 nginx配置

server {
    listen 80;
    server_name site2.com www.site2.com;
    access_log /var/log/nginx/site2.com.access.log;
    error_log /var/log/nginx/site2.com.error.log;
    location /
    {
        include uwsgi_params;
        uwsgi_pass unix:///tmp/uwsgi_site2.sock;
    }
    location ~ /\.    { access_log off; log_not_found off; deny all; }
    location ~ ~$     { access_log off; log_not_found off; deny all; }
}

supervisor配置

[program:site2]
command=/home/user/workspace/venvs/site2/env/bin/uwsgi -s /tmp/uwsgi_site2.sock -w runserver:app -H /home/user/workspace/venvs/site2/env --chmod-socket 666
directory=/home/user/workspace/venvs/site2
autostart=true
autorestart=true
stdout_logfile=/home/user/workspace/venvs/site2/uwsgi.log
redirect_stderr=true
stopsignal=QUIT

[program:site1]
command=/home/user/workspace/venvs/site1/env/bin/uwsgi -s /tmp/uwsgi_site1.sock -w wsgi:application -H /home/user/workspace/venvs/site1/env --chmod-socket 666
directory=/home/user/workspace/venvs/site1
autostart=true
autorestart=true
stdout_logfile=/home/user/workspace/venvs/site1/uwsgi.log
redirect_stderr=true
stopsignal=QUIT

[program:site3]
command=/home/user/workspace/venvs/site3/env/bin/uwsgi -s /tmp/uwsgi_site3.sock -w runserver:app -H /home/user/workspace/venvs/site3/env --chmod-socket 666
directory=/home/user/workspace/venvs/site3
autostart=true
autorestart=true
stdout_logfile=/home/user/workspace/venvs/site3/uwsgi.log
redirect_stderr=true
stopsignal=QUIT

site2 app

from site2 import app
from site2.database import init_db

try:
    init_db()
except:
    pass

if __name__ == '__main__':
    app.run()

site3 app

from site3 import app
from site3.database import init_db, init_testdata, test_db

if __name__ == '__main__':
    init_db()
    init_testdata()
    test_db()
    app.run()

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd20250.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年03月18日 - 00时23分18秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules