Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Supervisor a lot, and in this project I have an nginx process managed by Supervisord. The relevant parts of the configuration is this:

[supervisord]
logfile=/home/projects/eceee-web/prod/var/log/supervisord.log
logfile_maxbytes=5MB
logfile_backups=10
loglevel=info
pidfile=/home/projects/eceee-web/prod/var/supervisord.pid ;
childlogdir=/home/projects/eceee-web/prod/var/log
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)
directory=/home/projects/eceee-web/prod

[program:nginx]
command = /home/projects/eceee-web/prod/bin/nginx
redirect_stderr = true
autostart= true
autorestart = true
directory = /home/projects/eceee-web/prod
stdout_logfile = /home/projects/eceee-web/prod/var/log/nginx-stdout.log
stderr_logfile = /home/projects/eceee-web/prod/var/log/nginx-stderr.log

The /home/projects/eceee-web/prod/bin/nginx command will start nginx in the foreground, it does not deamonify itself. Still, stopping it will fail:

supervisorctl stop nginx

Will not give any answer, but the process will continue. Any idea what?

This is on OS X Darwin, with Supervisor 3.0a9 and nginx 0.7.65.

share|improve this question

2 Answers 2

You should be able to use the "daemon off" directive in nginx.conf.

http://wiki.nginx.org/CoreModule#daemon

share|improve this answer
    
It is off. As mentioned, nginx does not deamonify itself, so that's not the problem. –  Lennart Regebro Dec 31 '10 at 10:38
up vote 1 down vote accepted

OK, the problem was this:

I need to start nginx with LD_LIBRARY_PATH set so that pcre, libxslt and libxml are in the path (this is all custom builds with a buildout for easy environment replicaion).

Therefore I have a sh script that sets LD_LIBRARY_PATH and then starts nginx, so I don't have to set it explicitly if I want to start nginx.

And of course I let nginx just start that script.

But then, when it terminates that parent process, nginx doesn't die!

It seems nginx detaches itself from the shell that started it, even when not running in daemon mode.

Solution: Call the nginx binary directly, with the correct environment setting:

[program:nginx]
command = /Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/parts/nginx/sbin/nginx
environment = LD_LIBRARY_PATH="/Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/parts/lxml/libxml2/lib:/Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/parts/lxml/libxslt/lib:/Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/parts/pcre/lib"
redirect_stderr = true
autostart= true
autorestart = true
directory = /Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging
stdout_logfile = /Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/var/log/nginx-stdout.log
stderr_logfile = /Volumes/Macintosh-HD2/ServiceData/Web/eceee.org/staging/var/log/nginx-stderr.log
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.