Use supervisor as The uWSGI Daemon (continued)

Source: Internet
Author: User
Using supervisor is not very complicated. it is used to start uWSGI, but there are still some minor problems during the test, but there is no reason in the log, the root cause can be found only after careful consideration.

After the supervisor is started, it is normal to use supervisorctl to stop a program, but an error occurs when it is started again. I always thought that there was a problem with the configuration of the supervisor. check the logs of some supervisor:

2012-09-11 11:29:58,226 INFO supervisord started with pid 951 2012-09-11 11:29:59,230 INFO spawned: 'push_web_app' with pid 1203 2012-09-11 11:29:59,288 INFO exited: push_web_app (exit status 1; not expected) 2012-09-11 11:30:00,305 INFO spawned: 'push_web_app' with pid 1204 2012-09-11 11:30:00,316 INFO exited: push_web_app (exit status 1; not expected) 2012-09-11 11:30:02,320 INFO spawned: 'push_web_app' with pid 1205 2012-09-11 11:30:02,331 INFO exited: push_web_app (exit status 1; not expected) 2012-09-11 11:30:05,337 INFO spawned: 'push_web_app' with pid 1207 2012-09-11 11:30:05,348 INFO exited: push_web_app (exit status 1; not expected) 2012-09-11 11:30:06,350 INFO gave up: push_web_app entered FATAL state, too many start retries too quickly 

However, the configuration file cannot be modified. check the uwsgi log if uWSGI is faulty:

*** Starting uWSGI 1.2.5 (64bit) on [Tue Sep 11 11:30:49 2012] *** compiled with version: 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) on 06 September 2012 14:23:41 detected number of CPU cores: 4 current working directory: /Users/lch detected binary path: /Users/lch/.pythonbrew/venvs/Python-2.6.7/env_uwsgi/bin/uwsgi your memory page size is 4096 bytes detected max file descriptor number: 2560 lock engine: OSX spinlocks probably another instance of uWSGI is running on the same address. bind(): Address already in use [socket.c line 751] supervisor: error trying to setuid to 501 (Can't drop privilege as nonroot user) 

The second last sentence shows the cause of the error. Therefore, kill all the supervisor and uwsgi, restart the supervisor, and stop, ps aux | grep uwsgi found that another uwsgi process was not completed, so the sudo kill pid manually ended the process, and then started through supervisorctl, and finally OK.

The cause of the problem is found here, and the solution is also clarified: stop all uwsgi processes when the supervisor is stopped. the root cause is that the uwsgi configuration has a problem at startup. The startup parameter workers configured for uwsgi is 2, and two uwsgi processes will be started, and only one uwsgi process will be stopped by supervisorctl, then there must be a main process to control them, and inadvertently see a WARNING in The uwsgi startup log:

*** Starting uWSGI 1.2.5 (64bit) on [Tue Sep 11 10:53:17 2012] *** compiled with version: 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) on 06 September 2012 14:23:41 detected number of CPU cores: 4 current working directory: /Users/lch detected binary path: /Users/lch/.pythonbrew/venvs/Python-2.6.7/env_uwsgi/bin/uwsgi *** WARNING: you are running uWSGI without its master process manager *** 

So I added a -- master 1 parameter and a -- no-orphans parameter to kill all uwsgi processes after the master process is completed. After the modification, kill all the related processes again, and then try again:

supervisord ——> supervisorctl stop ——> supervisorctl start

Everything is normal, and the real-time monitoring process is also normal.

So far, learning how to deploy WEB with Nginx + uWSGI + Pyramid + Supervisor has come to an end.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.