]> git.pld-linux.org Git - packages/nginx.git/blobdiff - nginx.init
Up to 1.21.4.
[packages/nginx.git] / nginx.init
index f209fc06a855779ad8130418cf3ef5865dee7f77..1d62b97a8577ea655521e4496666881d7440489d 100755 (executable)
@@ -133,20 +133,29 @@ condrestart() {
 # http://nginx.org/en/docs/control.html#upgrade
 # TODO: handle revert back on failed upgrade
 upgrade() {
-       local oldbin_pidfile="${pidfile}.oldbin"
+       local oldbin_pidfile="${pidfile}.oldbin" retry
 
        checkconfig
        show "Upgrading $svname"
        killproc -p $pidfile $prog -USR2
        RETVAL=$?
-       sleep 1
-       if [ -f $oldbin_pidfile ] && [ -f $pidfile ]; then
-               show "Upgrade: stopping old process"
-               killproc -p $oldbin_pidfile $prog -QUIT
-               return 0
-       else
-               return 1
-       fi
+
+       # wait for 15s
+       retry=60
+       while [ $retry -gt 0 ]; do
+               if [ -f $oldbin_pidfile ] && [ -f $pidfile ]; then
+                       show "Upgrade: stopping old process"
+                       killproc -p $oldbin_pidfile $prog -QUIT
+                       return 0
+               else
+                       usleep 250000
+                       retry=$(($retry -1))
+               fi
+       done
+
+       show "Upgrade: stopping old process"; fail
+       nls 'old process pid file was not found'
+       return 1
 }
 
 # Tell nginx to reopen logs
This page took 0.024911 seconds and 4 git commands to generate.