Avoid hardcoded value in unicorn_launcher take 2.

This commit is contained in:
Guo Xiang Tan 2018-10-04 17:13:17 +08:00
parent 943f017a17
commit 16dedb5498

View File

@ -15,9 +15,20 @@ function on_reload()
{
echo "Reloading unicorn"
kill -s USR2 $UNICORN_PID
sleep 10
unset NEW_UNICORN_PID
while [ -z "$NEW_UNICORN_PID" ]; do
NEW_UNICORN_PID=`ps -f --ppid $UNICORN_PID | grep 'unicorn master' | grep -v old | grep -v worker | awk '{ print $2 }'`
echo "Waiting for new unicorn master pid... $NEW_UNICORN_PID"
sleep 1
done
while [ -z `ps -f --ppid $NEW_UNICORN_PID | grep worker | head -1 | awk '{ print $2 }'` ]; do
echo "Waiting for new unicorn workers to start up..."
sleep 1
done
curl $LOCAL_WEB &> /dev/null
NEW_UNICORN_PID=`ps -f --ppid $UNICORN_PID | grep unicorn | grep -v worker | awk '{ print $2 }'`
kill -s QUIT $UNICORN_PID
echo "Old pid is: $UNICORN_PID New pid is: $NEW_UNICORN_PID"
UNICORN_PID=$NEW_UNICORN_PID