675c6e
#!/bin/sh
675c6e
[ ! -f /run/nginx.pid ] && exit 1
675c6e
echo "Start new nginx master..."
675c6e
/bin/systemctl kill --signal=SIGUSR2 nginx.service
675c6e
sleep 5
675c6e
[ ! -f /run/nginx.pid.oldbin ] && sleep 10
675c6e
if [ ! -f /run/nginx.pid.oldbin ]; then
675c6e
    echo "Failed to start new nginx master."
675c6e
    exit 1
675c6e
fi
675c6e
echo "Stop old nginx master gracefully..."
675c6e
oldpid=`/usr/bin/cat /run/nginx.pid.oldbin 2>/dev/null`
675c6e
/bin/kill -s QUIT $oldpid 2>/dev/null
675c6e
sleep 5
675c6e
[ -f /run/nginx.pid.oldbin ] && sleep 10
675c6e
if [ -f /run/nginx.pid.oldbin ]; then
675c6e
    echo "Failed to stop old nginx master."
675c6e
    exit 1
675c6e
fi