Permalink
Browse files

Prevent start if the pid file is there.

  • Loading branch information...
sbisbee committed Sep 1, 2010
1 parent c307979 commit 0b9cf6dfca6ce1c0519f9cd0bdc89847fd31b558
Showing with 17 additions and 3 deletions.
  1. +17 −3 src/main/bin/run
View
20 src/main/bin/run 100644 → 100755
@@ -1,12 +1,19 @@
#!/bin/sh
+NAME="couchdb-lucene"
BACKGROUND=false #whether to run in the background or not
STDOUT_FILE="" #where to send background stdout to (defaults to &1)
PID_FILE="/var/run/couchdb-lucene/couchdb-lucene.pid"
SCRIPT_OK=0
SCRIPT_ERROR=1
+getPid()
+{
+ [ -f $PID_FILE ] && PID=`cat $PID_FILE`
+ echo $PID
+}
+
start()
{
JAVA_OPTS="-server -Xmx1g"
@@ -24,10 +31,17 @@ start()
then
eval $command
else
- [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE"
+ PID=`getPid`
+
+ if [ -z "$PID" ]
+ then
+ [ -n $STDOUT_FILE ] && command="$command >> $STDOUT_FILE"
- eval "$command &"
- echo $! > $PID_FILE
+ eval "$command &"
+ echo $! > $PID_FILE
+ else
+ echo "$NAME is already running ($PID_FILE)."
+ fi
fi
}

0 comments on commit 0b9cf6d

Please sign in to comment.