From 0459e242fcceb63e10e1f4ff638c49929c0ec9ce Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 17 Mar 2014 13:20:07 -0400 Subject: [PATCH] resolved #1223 --- nodebb | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/nodebb b/nodebb index 6f69fc6dba..41c6c95c85 100755 --- a/nodebb +++ b/nodebb @@ -4,6 +4,19 @@ # $1 action # $2 subaction +function pidExists() { + if [ -e "pidfile" ]; + then + kill -s 0 $(cat pidfile); + if [ !$? ]; + then return 1; + else return 0; + fi + else + return 0; + fi +} + case "$1" in start) echo "Starting NodeBB"; @@ -15,12 +28,28 @@ case "$1" in stop) echo "Stopping NodeBB. Goodbye!"; - kill `cat pidfile`; + kill $(cat pidfile); ;; reload|restart) echo "Restarting NodeBB."; - kill -1 `cat pidfile`; + kill -1 $(cat pidfile); + ;; + + status) + pidExists; + if [ 0 -eq $? ]; + then + echo "NodeBB is not running"; + echo " \"./nodebb start\" to launch the NodeBB server"; + return 1; + else + echo "NodeBB Running (pid $(cat pidfile))"; + echo " \"./nodebb stop\" to stop the NodeBB server"; + echo " \"./nodebb log\" to view server output"; + echo " \"./nodebb restart\" to restart NodeBB"; + return 0; + fi ;; log)