From d95398f8081aab2e18f62ac7ad47aa2727a0512d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 17 Apr 2014 12:09:42 -0400 Subject: [PATCH] more graceful handling of missing pidfile, #1395 --- nodebb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/nodebb b/nodebb index bf7b82e42e..e88744c081 100755 --- a/nodebb +++ b/nodebb @@ -33,13 +33,25 @@ case "$1" in ;; stop) - echo "Stopping NodeBB. Goodbye!"; - kill $(cat pidfile); + pidExists; + if [ 0 -eq $? ]; + then + echo "NodeBB is already stopped."; + else + echo "Stopping NodeBB. Goodbye!"; + kill $(cat pidfile); + fi ;; reload|restart) - echo "Restarting NodeBB."; - kill -1 $(cat pidfile); + pidExists; + if [ 0 -eq $? ]; + then + echo "NodeBB could not be restarted, as a running instance could not be found."; + else + echo "Restarting NodeBB."; + kill -1 $(cat pidfile); + fi ;; status)