LP#1908455 - Prevent multiple server processes
authorClayton Liddell <clayton@librarymarket.com>
Wed, 16 Dec 2020 22:12:44 +0000 (16:12 -0600)
committerJason Boyer <JBoyer@equinoxOLI.org>
Thu, 29 Dec 2022 18:32:54 +0000 (13:32 -0500)
Check for the existence of a server process before creating a new
server process in oils_ctl.sh.

Signed-off-by: Clayton Liddell <clayton@librarymarket.com>
Signed-off-by: Jason Boyer <JBoyer@equinoxOLI.org>
Open-ILS/examples/oils_ctl.sh

index c6bab4b..0e80af8 100755 (executable)
@@ -76,7 +76,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;
@@ -85,7 +85,7 @@ function do_action {
 
                if [ ! -e $pidfile ]; then
                        echo "$item not running";
-                       return 0;
+                       return 1;
                fi;
 
                pid=$(cat $pidfile);
@@ -105,13 +105,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;
 }
 
@@ -121,10 +122,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;
 }