Using nginx with a supervisor - nginx process running multiple times, resulting in a binding error

I am using nginx with Supervisor. The contents of my supervisord.conf file are as follows:

[supervisord] nodaemon=true logfile=/var/log/supervisor/supervisord.log [program:nginx] command=/usr/sbin/nginx -c /etc/nginx/nginx.conf stdout_logfile=/var/log/supervisor/%(program_name)s.log stderr_logfile=/var/log/supervisor/%(program_name)s.log redirect_stderr=true [supervisorctl] serverurl=unix:///tmp/supervisor.sock [unix_http_server] file=/tmp/supervisor.sock ; path to your socket file [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 

I started the supervisor after ensuring that netstat -nltp says that all ports are free, but please find the nginx error log below:

 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:81 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:18081 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:18082 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:18083 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:10080 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:8080 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:28080 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:18080 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:20081 failed (98: Address already in use) 2014/09/10 20:39:00 [emerg] 277#0: bind() to 0.0.0.0:81 failed (98: Address already in use) 

But the netstat -nltp command gives me the following:

 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:28080 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:20081 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:18080 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:10080 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:18081 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:18082 0.0.0.0:* LISTEN 246/nginx: master p tcp 0 0 0.0.0.0:18083 0.0.0.0:* LISTEN 246/nginx: master p 

This means that nginx is up and running. But the supervisor is trying to start several nginx processes or is not receiving a signal from nginx that it was running. Can anyone shed some light on this?

+6
source share
1 answer

You must add -g 'daemon off;' to nginx arguments.

The supervisor expects the service to work in the foreground. By default, nginx disables (demonizes) the background and exits. The supervisor will think that nginx is dead when it exits and tries to restart.

In older versions of nginx daemon off was discouraged, but this is no longer the case.

+1
source

Source: https://habr.com/ru/post/975092/


All Articles