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