# Recommended method to update binary from script

**URL:** <https://www.ruby-forum.com/t/recommended-method-to-update-binary-from-script/192692>\
**Category:** NGINX\
**Created:** [August 4, 2010, 5:30am UTC](https://www.ruby-forum.com/t/recommended-method-to-update-binary-from-script/192692 "2010-08-04T05:30:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shugyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@shugyo](https://www.ruby-forum.com/u/shugyo)\
**Post date:** [August 4, 2010, 5:30am UTC](https://www.ruby-forum.com/t/recommended-method-to-update-binary-from-script/192692/1 "2010-08-04T05:30:33Z")

</div>

Dear all,

I have trouble updating the nginx binary without downtime, from a  
script.

The company I work for runs nginx (0.7.64) as a front-end and apache  
(1.3.37 with mod\_perl) as a back-end web server on CentOS 4.8 on  
VMWare ESX virtual machines.

I need to update the nginx binary to version 0.7.67 on one  
production server, without downtime, and after searching found one  
method is to send the following sequence of commands to the nginx  
master process to get a “graceful” switchover after replacing the  
binary:

kill -USR2 # to start a 2nd (new) master & workers  
kill -WINCH # to kill old workers  
kill -QUIT # to shut down old master, PPID becomes 1

This sequence works fine from the command line. It also works fine  
from a script on a fast standalone test system running CentOS 5.5. But  
on a (less powerful) VMWare clone of the production server, with  
CentOS 4.8, the last signal when executed within a shell script kills  
the entire nginx, including the new master and workers.

I found that if I insert a pause (2 seconds) before the QUIT signal  
all is well, but I am not sure of the recommended method. Now I  
replaced the pause with a search for the new master process (PID new,  
PPID equals the old master process), and that also works for me for  
now.

I expect that the handling of signals takes some time, but would  
appreciate any pointers on what to check for in order to know that it  
is safe to execute further signal.

Best regards,  
Gernot H.  
Asahi-Net, Tokyo, Japan

Posted at Nginx Forum:

> **[Recommended method to update binary from script](https://forum.nginx.org/read.php?2,116377,116377#msg-116377)**
>
> Dear all, I have trouble updating the nginx binary without downtime, from a script. The company I work for runs nginx (0.7.64) as a front-end and apache (1.3.37 with mod\_perl) as a back-end web server on CentOS 4.8 on VMWare ESX virtual machines.

---

<div class="post-metadata">

**Author:** ![shugyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@shugyo](https://www.ruby-forum.com/u/shugyo)\
**Post date:** [August 4, 2010, 1:14pm UTC](https://www.ruby-forum.com/t/recommended-method-to-update-binary-from-script/192692/2 "2010-08-04T13:14:50Z")

</div>

Thank you Mr. Sysoev, those actions worked perfectly for me.  
Best regards,  
Gernot H.  
Asahi-Net, Tokyo, Japan

Posted at Nginx Forum:

> **[Re: Recommended method to update binary from script](https://forum.nginx.org/read.php?2,116377,116392#msg-116392)**
>
> Dear all, I have trouble updating the nginx binary without downtime, from a script. The company I work for runs nginx (0.7.64) as a front-end and apache (1.3.37 with mod\_perl) as a back-end web server on CentOS 4.8 on VMWare ESX virtual machines.

---

<div class="post-metadata">

**Author:** ![shugyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@shugyo](https://www.ruby-forum.com/u/shugyo)\
**Post date:** [August 4, 2010, 5:38am UTC](https://www.ruby-forum.com/t/recommended-method-to-update-binary-from-script/192692/3 "2010-08-04T05:38:45Z")

</div>

On Tue, Aug 03, 2010 at 11:29:55PM -0400, shugyo wrote:

> production server, without downtime, and after searching found one  
> on a (less powerful) VMWare clone of the production server, with  
> appreciate any pointers on what to check for in order to know that it  
> is safe to execute further signal.

Yes, the pause is safe.  
Please look at the “upgrade” target in Makefile:

upgrade:  
nginx.exe -t

```
    kill -USR2 `nginx.pid`
    sleep 1
    test -f nginx.pid.oldbin

    kill -QUIT `cat nginx.pid.oldbin`

```

You may omit -WINCH, it’s not required for this procedure.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
