JiaLiangC commented on code in PR #146:
URL: https://github.com/apache/ambari-metrics/pull/146#discussion_r2025937593


##########
ambari-metrics-grafana/conf/unix/ambari-metrics-grafana:
##########
@@ -89,7 +89,22 @@ fi
 DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} 
cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR}"
 
 function isRunning() {
-  test -e "$PID_FILE"
+  if [ -f ${PID_FILE} ]; then
+    PID=`cat ${PID_FILE}`
+    if [ -z "`ps ax -o pid | grep -w ${PID}`" ]; then
+      echo "${PID_FILE} found with no process. Removing ${PID}..."
+      rm -f ${PID_FILE}
+      return 1
+    else
+      tput bold
+      echo "WARN: Grafana already running with PID: ${PID}"
+      tput sgr0
+      echo "Exiting."
+      return 0
+    fi
+  else
+    return 1

Review Comment:
   There is a case where the PID file does not exist, but the process is still 
running.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to