Notice: wp_deregister_script的调用方法不正确。脚本和样式应在wp_enqueue_scriptsadmin_enqueue_scriptslogin_enqueue_scripts钩子之后再加入加载队列(enqueue)或注册(register)。 This notice was triggered by the l10n handle. 请查阅调试WordPress来获取更多信息。 (这个消息是在3.3.0版本添加的。) in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 5225

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-banner.php on line 11

Deprecated: 在d_banner中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-slidebanner.php on line 11

Deprecated: 在d_slidebanner中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-readers.php on line 11

Deprecated: 在d_reader中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-postlist.php on line 11

Deprecated: 在d_postlist中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-comment.php on line 11

Deprecated: 在d_comment中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-tags.php on line 11

Deprecated: 在d_tag中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866

Notice: Undefined variable: control_ops in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/widgets/wid-textbanner.php on line 11

Deprecated: 在d_textbanner中为WP_Widget调用的构造函数已自版本4.3.0起废弃!请改用__construct()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4866
【已解决】Flask的gunicorn的启动任务管理supervisor – 在路上
最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】Flask的gunicorn的启动任务管理supervisor

Flask crifan 2559浏览 0评论

目前,对于Flask项目,每次重新启动时,都很麻烦,需要:

手动去kill掉对应的进程,且要等一段时间:

等之前的4个workker都退出了:

(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast netstat -tulpn | grep 21084 
tcp        0      0 0.0.0.0:21084               0.0.0.0:*                   LISTEN      1312/python         
(RunningFast) ➜  RunningFast kill -9 1312
[1]  + 1312 killed     gunicorn -w 4 -b 0.0.0.0:21084 run:app                                                                                                                           
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast [2016-09-29 20:25:10 +0000] [1322] [INFO] Parent changed, shutting down: <Worker 1322>
[2016-09-29 20:25:10 +0000] [1322] [INFO] Worker exiting (pid: 1322)
[2016-09-29 20:25:10 +0000] [1323] [INFO] Parent changed, shutting down: <Worker 1323>
[2016-09-29 20:25:10 +0000] [1323] [INFO] Worker exiting (pid: 1323)
[2016-09-29 20:25:10 +0000] [1328] [INFO] Parent changed, shutting down: <Worker 1328>
[2016-09-29 20:25:10 +0000] [1328] [INFO] Worker exiting (pid: 1328)
[2016-09-29 20:25:10 +0000] [1329] [INFO] Parent changed, shutting down: <Worker 1329>
[2016-09-29 20:25:10 +0000] [1329] [INFO] Worker exiting (pid: 1329)
(RunningFast) ➜  RunningFast 
(RunningFast) ➜  RunningFast

才能重启Flask:

gunicorn -w 4 -b 0.0.0.0:21084 run:app &

现在希望:

把之前看到的,好像叫做supervisor的,用于任务管理的东西加进来:

可以使得每次重新启动Flask不再这么麻烦,只需要运行一个命令就好,比如restart之类的。

flask gunicorn task 管理

用gunicorn和gevent提高python web框架的性能 | 峰云就她了

李俊伟-随笔 – Flask部署

python web 部署:nginx + gunicorn + supervisor + flask 部署笔记 – Python – 伯乐在线

(RunningFast) ➜  RunningFast pip install supervisor
Collecting supervisor
  Downloading supervisor-3.3.1.tar.gz (415kB)
    100% |████████████████████████████████| 419kB 31kB/s 
Collecting meld3>=0.6.5 (from supervisor)
  Downloading meld3-1.0.2-py2.py3-none-any.whl
Building wheels for collected packages: supervisor
  Running setup.py bdist_wheel for supervisor … done
  Stored in directory: /root/.cache/pip/wheels/13/ea/25/c236d39561d2be9c427655e5d48d0bd2b75dc8e7e8b51d029d
Successfully built supervisor
Installing collected packages: meld3, supervisor
Successfully installed meld3-1.0.2 supervisor-3.3.1

【已解决】安装了supervisor后找不到/etc/supervisord.conf和supervisor

然后自己去使用配置去折腾,结果运行没反应的感觉:

【已解决】supervisor调用gunicorn去运行Flask的app没反应

然后此处即可通过:

[program:runningfast]
directory=/root/RunningFast
command=/root/Envs/RunningFast/bin/gunicorn -w 4 -b 0.0.0.0:21084 run:app &
startsecs=0
stopwaitsecs=0
autostart=false
autorestart=false
stdout_logfile=/root/RunningFast/logs/gunicorn.log
stderr_logfile=/root/RunningFast/logs/gunicorn.err

的配置,以及:

1.去启动supervisord:

supervisord -c supervisor.conf

2.(在配置文件改动的情况下)重新加载

supervisorctl -c supervisor.conf reload

3.去启动和停止自己的Flask的app:

supervisorctl -c supervisor.conf start runningfast
supervisorctl -c supervisor.conf stop runningfast
supervisorctl -c supervisor.conf restart runningfast

之后每次即可运行上述两个命令去启动和停止即可。

另外:

<code>supervisorctl -c supervisor.conf status
</code>

可以查看状态。

转载请注明:在路上 » 【已解决】Flask的gunicorn的启动任务管理supervisor


Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /data/wwwroot/www.crifan.com/wp-content/themes/daqianduan-d8-jquiss/comments.php on line 17

Deprecated: 自4.5.0版本起,已不建议使用get_currentuserinfo,请换用wp_get_current_user()。 in /data/wwwroot/www.crifan.com/wp-includes/functions.php on line 4773
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
46 queries in 0.393 seconds, using 18.75MB memory