From 58b2d23bf2e8916032f2c392f5a63b34f09d8d29 Mon Sep 17 00:00:00 2001 From: Clayton Liddell Date: Wed, 16 Dec 2020 16:12:44 -0600 Subject: [PATCH] LP#1908455 - Prevent multiple server processes Check for the existence of a server process before creating a new server process in oils_ctl.sh. Signed-off-by: Clayton Liddell --- Open-ILS/examples/oils_ctl.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Open-ILS/examples/oils_ctl.sh b/Open-ILS/examples/oils_ctl.sh index dde70cb1fc..ad78909491 100755 --- a/Open-ILS/examples/oils_ctl.sh +++ b/Open-ILS/examples/oils_ctl.sh @@ -69,7 +69,7 @@ function do_action { if [ -e $pidfile ]; then pid=$(cat $pidfile); echo "$item already started : $pid"; - return 0; + return 1; fi; echo "Starting $item"; fi; @@ -78,7 +78,7 @@ function do_action { if [ ! -e $pidfile ]; then echo "$item not running"; - return 0; + return 1; fi; pid=$(cat $pidfile); @@ -98,13 +98,14 @@ function do_action { function start_sip { - do_action "start" $PID_SIP "OILS SIP Server"; - DIR=$(pwd); - cd $SIP_DIR; - perl SIPServer.pm "$OPT_SIP_CONFIG" >> "$OPT_SIP_ERR_LOG" 2>&1 & - pid=$!; - cd $DIR; - echo $pid > $PID_SIP; + if do_action "start" $PID_SIP "OILS SIP Server"; then + DIR=$(pwd); + cd $SIP_DIR; + perl SIPServer.pm "$OPT_SIP_CONFIG" >> "$OPT_SIP_ERR_LOG" 2>&1 & + pid=$!; + cd $DIR; + echo $pid > $PID_SIP; + fi return 0; } @@ -114,10 +115,11 @@ function stop_sip { } function start_z3950 { - do_action "start" $PID_Z3950 "OILS Z39.50 Server"; - simple2zoom -c $OPT_Z3950_CONFIG -- -f $OPT_YAZ_CONFIG >> "$Z3950_LOG" 2>&1 & - pid=$!; - echo $pid > $PID_Z3950; + if do_action "start" $PID_Z3950 "OILS Z39.50 Server"; then + simple2zoom -c $OPT_Z3950_CONFIG -- -f $OPT_YAZ_CONFIG >> "$Z3950_LOG" 2>&1 & + pid=$!; + echo $pid > $PID_Z3950; + fi return 0; } -- 2.29.2