Skip to content

Commit

Permalink
start/stop/status: add some controls to make it more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
morind committed Dec 22, 2017
1 parent 10d31b6 commit ef2b536
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sensision/src/main/shell/sensision.init
Original file line number Diff line number Diff line change
Expand Up @@ -325,26 +325,30 @@ start() {
#
# Start..
#
su "${SENSISION_USER}" -c "${JAVA_HOME}/bin/java -Xmx${SENSISION_HEAP} ${SENSISION_OPTS} -Dsensision.config=${SENSISION_CONFIG} -cp ${SENSISION_CP} ${SENSISION_CLASS} >> ${SENSISION_HOME}/logs/nohup.out 2>&1 & echo $! > ${PID_FILE}"
su "${SENSISION_USER}" -c "${JAVA_HOME}/bin/java -Xmx${SENSISION_HEAP} ${SENSISION_OPTS} -Dsensision.config=${SENSISION_CONFIG} -cp ${SENSISION_CP} ${SENSISION_CLASS} >> ${SENSISION_HOME}/logs/nohup.out 2>&1 & echo \$! > ${PID_FILE}"

if [ ! -e ${PID_FILE} ]; then
if [ ! -e ${PID_FILE} ] || [ "`su \"${SENSISION_USER}\" -c \"${JAVA_HOME}/bin/jps -lm|grep -wE $(cat ${PID_FILE})|cut -f 1 -d' '\"`" == "" ]; then
echo "Start failed !"
rm -f ${PID_FILE}
exit 1
fi
}

stop() {
if [ -e ${PID_FILE} ] && [ "`su \"${SENSISION_USER}\" -c \"${JAVA_HOME}/bin/jps -lm|grep -wE $(cat ${PID_FILE})|cut -f 1 -d' '\"`" != "" ]; then
kill `su "${SENSISION_USER}" -c "${JAVA_HOME}/bin/jps -lm|grep -wE $(cat ${PID_FILE})|cut -f 1 -d' '"`
rm -f ${PID_FILE}
else
echo "No instance of Sensision is currently running"
fi
rm -f ${PID_FILE}
}

status() {
if [ -e ${PID_FILE} ]; then
if [ -e ${PID_FILE} ] && [ "`su \"${SENSISION_USER}\" -c \"${JAVA_HOME}/bin/jps -lm|grep -wE $(cat ${PID_FILE})|cut -f 1 -d' '\"`" != "" ]; then
su "${SENSISION_USER}" -c "${JAVA_HOME}/bin/jps -lm|grep -wE $(cat ${PID_FILE})"
else
echo "No instance of Sensision is currently running"
exit 1
fi
}

Expand Down

0 comments on commit ef2b536

Please sign in to comment.