search

Home  >  Q&A  >  body text

python - supervisor启动并监控gunicorn+flask的问题

各位 我当前用gunicorn + flask 的方式,用supervisor启动并监控,gunicorn是gevent加2个进程,supervisor配置如下:
[program:web]
directory=/usr/local/Web/app
command=python cli.py runserver
autostart=true
autorestart=true
startsecs=3
process_name=%(process_num)s
numprocs=2
stderr_logfile=/usr/local/Web/app/logs/err-%(process_num)s.log
stdout_logfile=/usr/local/Web/app/logs/out-%(process_num)s.log
pythonpath=@PYTHONPATH:/usr/local/web_venv/lib/python2.7/site-packages

当启动supervisord的时候 web:1可以正常启动,web:0无法启动:显示如下:
(web_venv) [root@godie conf.d]# supervisorctl
web:0 FATAL Exited too quickly (process log may have details)
web:1 RUNNING pid 22010, uptime 0:05:35

求助 如何让supervisor可以同时监控这两个进程呢?

PHPzPHPz2889 days ago558

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:54:04

    Supervisor is just a process guardian. If there is no problem if your command runs alone, then there will be no problem with supervisor. Now try not to open supervisor, but run python cli.py directly. Can runserver run normally?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:54:04

    1. When using gunicorn to start flask, you should not use python to start it, but use gunicorn myproject:app to refer to guncicorn;
    2. The two processes here should be controlled using gunicorn configuration, which is similar to supervisor guarding gunicorn (if it hangs, Restart), gunicorn manages two flask processes (sending web requests to flask for processing).

    Hope it helps you.

    reply
    0
  • Cancelreply