2

We use nginx on centos 6, and the init.d script from here: https://gist.github.com/sairam/5892520/raw/b8195a71e944d46271c8a49f2717f70bcd04bf1a/etc-init.d-nginx

It all "works"

Nginx runs, etc.

However, in certain cases after using this init.d script via ssh, the script, both via ssh and as root on the console, only appears to work.

E.g.

service nginx stop
[OK]

But nginx is still running....

service nginx restart
[OK]

But the service is running with same pid, and did not ever exit.

Rebooting the box seems to be the only way to properly get the service to stop and restart.

Full steps and problem shown below.

How do I approach this problem?

Here I log in as sysadmin, and then su up to run commands:

enter image description here

Here I just log in as root to begin with. Same issue:

enter image description here

5
  • 2
    Why are you using a third party init script? Both the nginx version that ships with CentOS, and the one in the nginx yum repositories, have working init scripts. – Michael Hampton Feb 5 '15 at 0:34
  • @MichaelHampton We are using the script our linux admin documented for us. We run nginx 1.7.9 that we compile from sources. Let me try to find a url for the scripts you refer to. – Jonesome Reinstate Monica Feb 5 '15 at 0:39
  • @MichaelHampton tried a stock init, but it is not set up for this env. the delta to the script we run is really tiny. – Jonesome Reinstate Monica Feb 5 '15 at 1:21
  • Instead of doing a restart, what happens if you do a kill <pid> and then a start? Same result? Anything in the logs that looks helpful? – shearn89 Feb 5 '15 at 11:05
  • @shearn89 We have narrowed the issue to nginx not exiting. See serverfault.com/q/666037/13716 – Jonesome Reinstate Monica Feb 9 '15 at 3:40
0

To answer: "how to work on this issue" the answer is to use the ps command:

ps -eaf|grep nginx

This shows that after issuing a stop or reload, that one or more nginx worker processes is stuck forever in "process is shutting down"

As a result, nginx never exits, and the whole situation is hosed until you kill the pid or issue nginx -s stop (which basically kills the pid, but is easier because you don't have to do a pid lookup).

It seems to have something to do with either the upstream check module or when used for web sockets.

The more specific issue has been posted here: nginx 1.7.9: Reverse Proxy Web Sockets: hangs on service stop / service restart, never exits

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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