ignatenkobrain / rpms / nginx

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