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

I use nginx as a reverse proxy. Whenever I update the config for it using

sudo "cp -r #{nginx_config_path}* /etc/nginx/sites-enabled/"
sudo "kill -s HUP `cat /var/run/nginx.pid`"

I face a brief downtime. How can I avoid that?

share|improve this question
    
It would be great if you could select the correct answer. –  Hengjie Jul 28 '12 at 2:42

2 Answers 2

up vote 27 down vote accepted

Run service nginx reload or /etc/init.d/nginx reload

It will do a hot reload of the configuration without downtime. If you have pending requests, then there will be lingering nginx processes that will handle those connections before it dies, so it's an extremely graceful way to reload configs.

Sometimes you may want to prepend with sudo

share|improve this answer
1  
Both of those should do exactly what the question states: send SIGHUP to the nginx master process. There should not be a difference. nginx.org/en/docs/control.html –  Gnarfoz Jul 27 '12 at 12:36

Usually, reloading configuration file of a service should not affect the running service. However, this depends on how the SIGHUP signal is processed.

If a specific service is experiencing a downtime during reload, this can be circumvented by running the same service on multiple servers preferably using a load balancer. In this case, you can take out one server at a time and reload/restart it. Then, it can be re-added after confirming it is OK.

share|improve this answer
    
While this does not directly answer the question, this is definitely a best-practice scenario that the OP would be smart to follow for avoiding downtime in general. –  Andrew M. Apr 11 '12 at 17:29
1  
Details on how nginx handles different signals: nginx.org/en/docs/control.html –  Gnarfoz Jul 27 '12 at 12:37

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.