Nginx Binary Live Upgrade
Ok, you have run Nginx-1.3.5 and want to upgrade binary without any downtime. With help of Unix Signals USR2+WINCH+QUIT it's easy and handy. Let's start with download of latest SPDY-pepper:
cd /usr/src;
wget http://nginx.org/download/nginx-1.3.14.tar.gz;
tar xzvf ./nginx-1.3.14.tar.gz && rm -f ./nginx-1.3.14.tar.gz && cd nginx-1.3.14;
wget http://nginx.org/patches/spdy/patch.spdy-66_1.3.14.txt && patch -p1 < patch.spdy-66_1.3.14.txt;
./configure --prefix=/opt/nginx --with-pcre=/usr/src/pcre-8.30 --with-zlib=/usr/src/zlib-1.2.7 --with-openssl-opt=no-krb5 --with-openssl=/usr/src/openssl-1.0.1c --with-http_ssl_module --with-http_spdy_module --without-mail_pop3_module --without-mail_smtp_module --without-mail_imap_module --with-http_stub_status_module --with-http_gzip_static_module;
make install clean;
Let's assume that the current Master PID is 19568, but the new Master PID is 22716.
Now we have to roll out the master processes:
1) $ ps aux |grep nginx
root 19568 ..... nginx: master (old)
app 20769 ..... nginx: worker (old)
2) $ kill -USR2 $(cat /opt/nginx/logs/nginx.pid);
$ ps aux |grep nginx
root 19568 ..... nginx: master (old)
app 20769 ..... nginx: worker (old)
root 22716 ..... nginx: master (new)
app 22717 ..... nginx: worker (new)
3) $ kill -WINCH $(cat /opt/nginx/logs/nginx.pid.oldbin);
$ ps aux |grep nginx
root 19568 ..... nginx: master (old)
root 22716 ..... nginx: master (new)
app 22717 ..... nginx: worker (new)
4) $ kill -QUIT $(cat /opt/nginx/logs/nginx.pid.oldbin);
$ ps aux |grep nginx
root 22716 ..... nginx: master (new)
app 22717 ..... nginx: worker (new)
TL;DR
kill -USR2 $(cat /opt/nginx/logs/nginx.pid);
kill -WINCH $(cat /opt/nginx/logs/nginx.pid.oldbin);
kill -QUIT $(cat /opt/nginx/logs/nginx.pid.oldbin);
Written by Anatoly
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nginx
Authors
reiaguilera
279.4K
jamesdullaghan
90.14K
Related Tags
#nginx
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#