ignatenkobrain / rpms / nginx

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