ignatenkobrain / rpms / nginx

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