Skip to content

Commit

Permalink
Merge pull request voxpupuli#94 from igalic/init-fix
Browse files Browse the repository at this point in the history
Init fix
  • Loading branch information
fessyfoo committed Aug 26, 2016
2 parents 5ea991f + dd1d520 commit a5a0106
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions templates/init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@ start() {
}

stop() {
if [ ! -f "$PID_FILE" ]; then
echo "$PID_FILE does not exist, process is not running"
return 1
if ! [ -f "$PID_FILE" ]; then
echo -n "$PID_FILE does not exist"
if PID=`pgrep -f "$PGREP_PATTERN"` ; then
echo -n ", but process is running"
echo "$PID" > "$PID_FILE"
else
echo -n ", and process is not running"
return 1
fi
fi

kill `cat "$PID_FILE"`;
Expand All @@ -107,13 +113,13 @@ stop() {
}

status() {
if [ ! -f "$PID_FILE" ]; then
if ! [ -f "$PID_FILE" ]; then
echo "$NAME stopped"
exit 1
fi

PID=`cat "$PID_FILE"`
if [ `ps -p "$PID" -o pid= || echo 1` -eq `pgrep -f "$PGREP_PATTERN" || echo 2` ] ; then
if ! [ `ps -p "$PID" -o pid= || echo 1` -eq `pgrep -f "$PGREP_PATTERN" || echo 2` ] ; then
echo "$NAME stopped but pid file exists"
exit 1
fi
Expand Down

0 comments on commit a5a0106

Please sign in to comment.