Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Post Installation script from debian that upgrades Nginx the proper way, i.e., without downtime
#!/bin/sh
set -e
case "$1" in
configure)
if [ -z $2 ] && [ ! -e /etc/nginx/sites-enabled/default ] ;
then
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
if [ -x /etc/init.d/nginx ]
then
if [ -f /var/run/nginx.pid ] && pidof /usr/sbin/nginx >/dev/null
then
echo "Trying a soft restart"
NGX_PID=`cat /var/run/nginx.pid`
if kill -s USR2 $NGX_PID 2>/dev/null
then
echo "PID IS RIGHT"
while [ ! -f /var/run/nginx.pid.oldbin ]
do
echo "WAITING"
cnt=`expr $cnt + 1`
if [ $cnt -gt 10 ]
then
echo "Nginx 'soft' update failed, doing restart"
kill -s KILL $NGX_PID
invoke-rc.d nginx start
exit 0
fi
sleep 1
done
echo "QUIT"
NGX_OLD_PID=`cat /var/run/nginx.pid.oldbin`
kill -s QUIT $NGX_OLD_PID
fi
fi
fi
#DEBHELPER#
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.