Pages

Bài đăng phổ biến

Showing posts with label Upgrade nginx on the fly - no downtime. Show all posts
Showing posts with label Upgrade nginx on the fly - no downtime. Show all posts

Sunday, October 9, 2022

Upgrade nginx on the fly - no downtime

          #first please check pid file by:

          cat /var/run/nginx.pid  

#copy new binary to /sbin/nginx and force overwrite if you don't use option "-f" you will see this error : 
cp: cannot create regular file ‘/sbin/nginx’: Text file busy
/bin/cp -f nginx /sbin/nginx 

#spawn a new nginx master/workers set

kill -s USR2 `cat /var/run/nginx.pid`

#check process

ps aux | grep nginx

# check pid 

tail -n +1 /var/run/nginx.pid*

#shut down the old master's worker

kill -s WINCH `cat /var/run/nginx.pid.oldbin`

#check 
ps aux | grep nginx

safely shut down the old master process

kill -s QUIT `cat /var/run/nginx.pid.oldbin`