From 3400624d70127a3f5857c7c1015de877eb10aa9a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 5 Oct 2018 11:48:32 +0800 Subject: [PATCH] Log pid of launcher script when logging. --- config/unicorn_launcher | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/config/unicorn_launcher b/config/unicorn_launcher index 8ad112065c2..481be1d6a76 100755 --- a/config/unicorn_launcher +++ b/config/unicorn_launcher @@ -5,39 +5,44 @@ LOCAL_WEB="http://127.0.0.1:3000/" +function log() +{ + echo "($$) $1" +} + function on_exit() { kill $UNICORN_PID - echo "exiting" + log "exiting" } function on_reload() { - echo "Reloading unicorn" + log "Reloading unicorn" kill -s USR2 $UNICORN_PID 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" + log "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..." + log "Waiting for new unicorn workers under $NEW_UNICORN_PID to start up..." sleep 1 done curl $LOCAL_WEB &> /dev/null kill -s QUIT $UNICORN_PID - echo "Old pid is: $UNICORN_PID New pid is: $NEW_UNICORN_PID" + log "Old pid is: $UNICORN_PID New pid is: $NEW_UNICORN_PID" UNICORN_PID=$NEW_UNICORN_PID } function on_reopenlogs() { - echo "Reopening logs" + log "Reopening logs" kill -s USR1 $UNICORN_PID }