nginx not removing stream socket

Anoop Alias anoopalias01 at gmail.com
Mon Jul 4 13:35:49 UTC 2016


Hi,

On CentOS7 . nginx is not removing the stream socket on shutdown
causing restarts to fail unless the socket file is manually removed.
nginx process itself exit .But becase of the file not being removed
nginx is unable to bind to the socket file on next start

systemd unit file
#######################

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
###########################

#nginx configuration

stream {
    upstream mysql_backend {
        server unix:/var/lib/mysql/mysql_original.sock;
        server x.x.x.x:13306 backup;
    }

    server {
        listen     127.0.0.1:3306;
        listen     unix:/var/lib/mysql/mysql.sock;
        proxy_pass mysql_backend;
    }
}
######################################

The same setting is working fine on a centos6 server with init .

which use the killproc function from /etc/rc.d/init.d/functions

Even on CentOS6 ..if I do

kill -QUIT <nginx_pid>

the binary exits without removing the socket.

What am I doing wrong?.

What is the correct signal to terminate the process and remove the
sockets bound.

Thanks,
-- 
Anoop P Alias



More information about the nginx mailing list