5

I will start with my use case, since I very well may not be using the correct tools for this job. Please let me know if I am going about this all the wrong way

use case: I have a CentOS server hosting multiple web apps. I want to be able to trust that my web server and application server will be running. My stack looks like

  • web server: nginx
  • application server: uWSGI
  • web framework: flask / python

I want to use supervisord to monitor nginx and uWSGI. In my /etc/supervisor.conf, I have

[program:nginxgo]
command = /usr/sbin/nginx
autostart=true
autorestart=unexpected
exitcodes=0
stdout_logfile=/home/webdev/nginxgo.log
stderr_logfile=/home/webdev/nginxgoerr.log

[program:uwsgi_emperor_go]
command = uwsgi --emperor /etc/uwsgi/emperor.ini
autostart=true
autorestart=unexpected
stopsignal=INT
stdout_logfile=/home/webdev/emp.log
stderr_logfile=/home/webdev/emperr.log
directory=/home/webdev/
user=webdev

I got the uWSGI process to start. When I enter [root@mymachine]# /usr/local/bin/supervisord -n -c /etc/supervisord.conf

the output is

2014-11-26 14:07:56,917 CRIT Supervisor running as root (no user in config file)
2014-11-26 14:07:56,951 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2014-11-26 14:07:56,952 INFO supervisord started with pid 31068
2014-11-26 14:07:57,957 INFO spawned: 'nginxgo' with pid 31071
2014-11-26 14:07:57,970 INFO spawned: 'uwsgi_emperor_go' with pid 31072
2014-11-26 14:07:59,095 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:07:59,095 INFO success: uwsgi_emperor_go entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:00,601 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:01,607 INFO spawned: 'nginxgo' with pid 31079
2014-11-26 14:08:02,684 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:04,189 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:05,194 INFO spawned: 'nginxgo' with pid 31080
2014-11-26 14:08:06,264 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:07,771 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:08,775 INFO spawned: 'nginxgo' with pid 31081
2014-11-26 14:08:09,808 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:11,314 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:12,319 INFO spawned: 'nginxgo' with pid 31082
2014-11-26 14:08:13,381 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:14,886 INFO exited: nginxgo (exit status 1; not expected)
^C2014-11-26 14:08:15,601 INFO spawned: 'nginxgo' with pid 31083
2014-11-26 14:08:15,603 WARN received SIGINT indicating exit request
2014-11-26 14:08:15,611 INFO waiting for nginxgo, uwsgi_emperor_go to die
2014-11-26 14:08:16,738 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:18,242 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:19,244 INFO waiting for uwsgi_emperor_go to die
2014-11-26 14:08:21,607 INFO stopped: uwsgi_emperor_go (exit status 0)

See how it says

2014-11-26 14:07:59,095 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:07:59,095 INFO success: uwsgi_emperor_go entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

but then it starts just cycling the nginxgo process. I kill the supervisord instance with CTRL-C, and I see in htop that the nginx master process and worker process are both active.

All I want is to start nginx and my uWSGI emperor on server startup/restart or failure of either program

1 Answer 1

10

supervisord can only handle processes in foreground. The default for nginx is running in background as daemon.

To ensure that your nginx is running with supervisord you have to set 'daemon off' in your nginx.conf (see also nginx docu at http://nginx.org/en/docs/ngx_core_module.html#daemon).

2
  • In the nginx config, enter daemon off then it works with supervisor Dec 5, 2014 at 13:52
  • Does the stop action work when you use this technique ? start worked for me after I added sudo in the supervisord command attribute. I tried running supervisorctl stop nginx and it complained with OSError.
    – JahMyst
    Feb 10, 2017 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .