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