ignatenkobrain / rpms / nginx

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