don't exit unless process has already started

This commit is contained in:
Adrian Cole 2011-07-07 01:12:09 -07:00
parent 712d50dea8
commit 0b4347772b
4 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@ function forget {
local LOG_DIR="$1"; shift local LOG_DIR="$1"; shift
mkdir -p $LOG_DIR mkdir -p $LOG_DIR
findPid $INSTANCE_NAME findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] && { [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID] echo $INSTANCE_NAME already running pid [$FOUND_PID]
} || { } || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &

View File

@ -26,7 +26,7 @@ function findPid {
return 1 return 1
} }
local PATTERN="$1"; shift local PATTERN="$1"; shift
local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'`
[ -n "$_FOUND" ] && { [ -n "$_FOUND" ] && {
export FOUND_PID=$_FOUND export FOUND_PID=$_FOUND
return 0 return 0
@ -45,7 +45,7 @@ function forget {
local LOG_DIR="$1"; shift local LOG_DIR="$1"; shift
mkdir -p $LOG_DIR mkdir -p $LOG_DIR
findPid $INSTANCE_NAME findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] && { [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID] echo $INSTANCE_NAME already running pid [$FOUND_PID]
} || { } || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &

View File

@ -24,7 +24,7 @@ function findPid {
return 1 return 1
} }
local PATTERN="$1"; shift local PATTERN="$1"; shift
local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'`
[ -n "$_FOUND" ] && { [ -n "$_FOUND" ] && {
export FOUND_PID=$_FOUND export FOUND_PID=$_FOUND
return 0 return 0
@ -43,7 +43,7 @@ function forget {
local LOG_DIR="$1"; shift local LOG_DIR="$1"; shift
mkdir -p $LOG_DIR mkdir -p $LOG_DIR
findPid $INSTANCE_NAME findPid $INSTANCE_NAME
[ -n "$FOUND_PID" ] && { [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && {
echo $INSTANCE_NAME already running pid [$FOUND_PID] echo $INSTANCE_NAME already running pid [$FOUND_PID]
} || { } || {
nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log &

View File

@ -14,7 +14,7 @@ function findPid {
return 1 return 1
} }
local PATTERN="$1"; shift local PATTERN="$1"; shift
local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'`
[ -n "$_FOUND" ] && { [ -n "$_FOUND" ] && {
export FOUND_PID=$_FOUND export FOUND_PID=$_FOUND
return 0 return 0