当uwsgi与主管一起工作时发生致命错误

问题描述 投票:0回答:2

我有一个使用nginx + uwsgi + flask的网站。我使用主管来控制uwsgi。使用uwsgi uwsgi_config.ini时效果很好

但是当使用主管时,它总会发出致命的错误,退出得太快。但是,uwsgi进程仍然在后台运行。这意味着我的网站仍在运行。

主管日志是这样的:

2017-04-28 21:22:25,771 CRIT Running without any HTTP authentication checking
2017-04-28 21:22:25,775 INFO daemonizing the process
2017-04-28 21:22:25,775 INFO supervisord started with pid 5246
2017-04-28 21:22:25,776 INFO spawned: 'access_token' with pid 5248
2017-04-28 21:22:25,778 INFO spawned: 'ggc-mp' with pid 5249
2017-04-28 21:22:25,796 INFO exited: ggc-mp (exit status 0; not expected)
2017-04-28 21:22:25,796 INFO received SIGCLD indicating a child quit
2017-04-28 21:22:26,797 INFO success: access_token entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-04-28 21:22:26,799 INFO spawned: 'ggc-mp' with pid 5266
2017-04-28 21:22:26,807 INFO exited: ggc-mp (exit status 0; not expected)
2017-04-28 21:22:26,808 INFO received SIGCLD indicating a child quit
2017-04-28 21:22:28,811 INFO spawned: 'ggc-mp' with pid 5270
2017-04-28 21:22:28,819 INFO exited: ggc-mp (exit status 0; not expected)
2017-04-28 21:22:28,820 INFO received SIGCLD indicating a child quit
2017-04-28 21:22:31,824 INFO spawned: 'ggc-mp' with pid 5273
2017-04-28 21:22:31,833 INFO exited: ggc-mp (exit status 0; not expected)
2017-04-28 21:22:31,834 INFO received SIGCLD indicating a child quit
2017-04-28 21:22:32,835 INFO gave up: ggc-mp entered FATAL state, too many start retries too quickly

这是主管的配置文件:

[program:ggc-mp]
command=/home/www/bin/uwsgi /home/www/uwsgi_config.ini
directory=/home/www/ggc-mp
user=root
autostart=true
autorestart=true
stdout_logfile=/home/www/logs/uwsgi_supervisor.log
stderr_logfile=/home/www/logs/uwsgi_supervisor_err.log
priority=80

对于uwsgi,配置如下:

[uwsgi]
socket = 127.0.0.1:8001
chdir = /home/www/ggc-mp
wsgi-file = run.py 
callable = app 
processes = 1
enable-threads = true
stats = 127.0.0.1:9191
master = 1
no-orphans = true
daemonize = /home/www/logs/uwsgi.log

uwsgi的日志:

*** Starting uWSGI 2.0.15 (64bit) on [Fri Apr 28 21:22:25 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 27 April 2017 01:21:21
os: Linux-2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014
nodename: iZ944btl9ixZ
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /home/www/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /home/www/ggc-mp
your processes number limit is 7798
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8001 fd 3
Python version: 3.6.1 (default, Apr 26 2017, 23:51:23)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
Python main interpreter initialized at 0x243d8b0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** Starting uWSGI 2.0.15 (64bit) on [Fri Apr 28 21:22:26 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 27 April 2017 01:21:21
os: Linux-2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014
nodename: iZ944btl9ixZ
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /home/www/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /home/www/ggc-mp
your processes number limit is 7798
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
probably another instance of uWSGI is running on the same address (127.0.0.1:8001).
bind(): Address already in use [core/socket.c line 769]
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x243d8b0 pid: 5251 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 5251)
spawned uWSGI worker 1 (pid: 5269, cores: 1)
*** Stats server enabled on 127.0.0.1:9191 fd: 12 ***
/home/www/lib/python3.6/site-packages/pymongo/topology.py:145: UserWarning: MongoClient opened before fork. Create MongoClient with connect=False, or create client after forking. See PyMongo's documentation for details: http://api.mongodb.org/python/current/faq.html#pymongo-fork-safe>
  "MongoClient opened before fork. Create MongoClient "
No handler responded message <werobot.messages.events.ViewEvent object at 0x7ff178c7ffd0>
[pid: 5269|app: 0|req: 1/1] 58.247.206.153 () {44 vars in 789 bytes} [Fri Apr 28 21:22:28 2017] POST /werobot/?signature=262a145e32744ff1837ef9196991b13522848a2e&timestamp=1493385748&nonce=669799016&openid=o9nkNwnYrkS4RCUG7XgAa5NvT6mQ => generated 0 bytes in 306 msecs (HTTP/1.1 200) 3 headers in 109 bytes (1 switches on core 0)
[pid: 5269|app: 0|req: 2/2] 125.68.14.199 () {48 vars in 1396 bytes} [Fri Apr 28 21:22:28 2017] GET /disc/ => generated 277 bytes in 2 msecs (HTTP/1.1 302) 3 headers in 150 bytes (1 switches on core 0)
*** Starting uWSGI 2.0.15 (64bit) on [Fri Apr 28 21:22:28 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 27 April 2017 01:21:21
os: Linux-2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014
nodename: iZ944btl9ixZ
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /home/www/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /home/www/ggc-mp
your processes number limit is 7798
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
probably another instance of uWSGI is running on the same address (127.0.0.1:8001).
bind(): Address already in use [core/socket.c line 769]
[pid: 5269|app: 0|req: 3/3] 125.68.14.199 () {48 vars in 1454 bytes} [Fri Apr 28 21:22:28 2017] GET /disc/o9nkNwnYrkS4RCUG7XgAa5NvT6mQ/ => generated 4846 bytes in 693 msecs (HTTP/1.1 200) 2 headers in 81 bytes (1 switches on core 0)
No handler responded message <werobot.messages.events.ViewEvent object at 0x7ff178c7fe80>
[pid: 5269|app: 0|req: 4/4] 58.247.206.152 () {44 vars in 791 bytes} [Fri Apr 28 21:22:31 2017] POST /werobot/?signature=3c35ec864867a3bbd92c4280736945014a6c2209&timestamp=1493385751&nonce=1199266520&openid=o9nkNwnYrkS4RCUG7XgAa5NvT6mQ => generated 0 bytes in 50 msecs (HTTP/1.1 200) 3 headers in 109 bytes (1 switches on core 0)
[pid: 5269|app: 0|req: 5/5] 125.68.14.199 () {48 vars in 1398 bytes} [Fri Apr 28 21:22:31 2017] GET /order/ => generated 4746 bytes in 679 msecs (HTTP/1.1 200) 2 headers in 81 bytes (1 switches on core 0)
*** Starting uWSGI 2.0.15 (64bit) on [Fri Apr 28 21:22:31 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 27 April 2017 01:21:21
os: Linux-2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014
nodename: iZ944btl9ixZ
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /home/www/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /home/www/ggc-mp
your processes number limit is 7798
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
probably another instance of uWSGI is running on the same address (127.0.0.1:8001).
bind(): Address already in use [core/socket.c line 769]
[pid: 5269|app: 0|req: 6/6] 125.68.18.192 () {44 vars in 610 bytes} [Fri Apr 28 21:22:33 2017] GET /image/wx-share/pot.png => generated 43265 bytes in 8 msecs via sendfile() (HTTP/1.1 200) 8 headers in 288 bytes (0 switches on core 0)

有人可以帮忙吗?

python uwsgi supervisor
2个回答
1
投票

uWsgi进程已在端口上运行,您需要在尝试重新运行之前将其停止。

# If you have create uwsgi service
sudo service uwsgi stop

# If you are using emperor
sudo service emperor stop

# If nothing else works, then forcibly kill it
pkill -9 wsgi

1
投票

从uwsgi config.ini中删除一个配置后,问题就不再出现了问题,这是qazxsw poi

要使用日志记录,请尝试daemonize = /home/www/logs/uwsgi.log

© www.soinside.com 2019 - 2024. All rights reserved.