ignatenkobrain / rpms / nginx

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