ignatenkobrain / rpms / nginx

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