Browse Source

FIX #141 - Clean up sentinel creation

All currently used init scripts will now delete the sentinel file at
startup to avoid loops if the program fails to load entirely. Also
fix missing copyright on init scripts, and ensure that programs
create sentinel files at appropriate points (i.e. once all possible
startup errors have been checked and the process is in its ready state.

I have not cleaned up issues in the legacy startup scripts - I propose
to move them out of the repo shortly.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 years ago
parent
commit
a1fc50dc64

+ 1 - 1
dali/dafilesrv/dafilesrv.cpp

@@ -533,7 +533,6 @@ int main(int argc,char **argv)
             return ret;
 #endif
     }
-    writeSentinelFile(sentinelFile);
     logname.append("DAFILESRV");
     ILogMsgHandler * fileMsgHandler = getRollingFileLogMsgHandler(logname.str(), ".log", MSGFIELD_STANDARD, false, true, NULL);
     queryLogMsgManager()->addMonitorOwn(fileMsgHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, TopDetail));
@@ -549,6 +548,7 @@ int main(int argc,char **argv)
     PROGLOG("Authentication:%s required",requireauthenticate?"":" not");
     startPerformanceMonitor(10*60*1000, PerfMonStandard);
     server.setown(createRemoteFileServer());
+    writeSentinelFile(sentinelFile);
     try {
         server->run(listenep);
     }

+ 4 - 5
dali/sasha/start_sasha

@@ -16,8 +16,6 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ################################################################################
 
-
-
 ################################################# 
 ##    Defaulting needed for new init system    ## 
 ################################################# 
@@ -34,14 +32,15 @@ export PATH=$PATH
 export LANG=en_US
 export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
 export SENTINEL="saserver.sentinel"
+rm -f ${SENTINEL}
 nohup $BINDIR/saserver 1> /dev/null 2>&1 &
 echo $! > component.pid
 wait
 while [ -e ${SENTINEL} ]; do
-        sleep 5
-        if [ -e ${SENTINEL} ]; then
+    sleep 5
+    if [ -e ${SENTINEL} ]; then
         nohup $BINDIR/saserver 1> /dev/null 2>&1 &
         echo $! > component.pid
         wait
-        fi
+    fi
 done

+ 9 - 6
ecl/eclccserver/start_eclccserver

@@ -15,17 +15,20 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ################################################################################
 
-export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH 
-export PATH=.:$PATH 
-export LANG=en_US 
-ulimit -c unlimited 
+export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
+export PATH=.:$PATH
+export LANG=en_US
+ulimit -c unlimited
 export SENTINEL="eclccserver.sentinel"
+rm -f $SENTINEL
 nohup $PWD/eclccserver 1>/dev/null 2>/dev/null &
 echo $! > component.pid
-wait 
+wait
 if [ -e ${SENTINEL} ]; then
     sleep 5
     if [ -e ${SENTINEL} ]; then
-        ./startup
+        nohup $PWD/eclccserver 1>/dev/null 2>/dev/null &
+        echo $! > component.pid
+        wait
     fi
 fi

+ 2 - 3
ecl/eclscheduler/eclscheduler.cpp

@@ -208,9 +208,6 @@ int main(int argc, const char *argv[])
     try
     {
         initClientProcess(serverGroup, DCR_EclServer);
-        // if we got here, eclscheduler is successfully started and all options are good, so create the "sentinel file" for re-runs from the script
-        // put in its own "scope" to force the flush
-        writeSentinelFile(sentinelFile);
         Owned <IStringIterator> targetClusters = getTargetClusters("EclSchedulerProcess", globals->queryProp("@name"));
         if (!targetClusters->first())
             throw MakeStringException(0, "No clusters found to schedule for");
@@ -223,6 +220,8 @@ int main(int argc, const char *argv[])
             scheduler->start();
             schedulers.append(*scheduler.getClear());
         }
+        // if we got here, eclscheduler is successfully started and all options are good, so create the "sentinel file" for re-runs from the script
+        writeSentinelFile(sentinelFile);
         LocalIAbortHandler abortHandler(waiter);
         waiter.wait();
         ForEachItemIn(schedIdx, schedulers)

+ 1 - 0
esp/platform/espp.cpp

@@ -265,6 +265,7 @@ int init_main(int argc, char* argv[])
     CEspAbortHandler abortHandler;
 
     Owned<IFile> sentinelFile = createSentinelTarget();
+    removeSentinelFile(sentinelFile);
 
     Owned<CEspConfig> config;
     Owned<CEspServer> server;

+ 23 - 6
initfiles/bin/init_configesp

@@ -1,5 +1,21 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
+
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +25,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="configesp.sentinel"
+rm -f ${SENTINEL}
 
 ulimit -c unlimited
 ulimit -n 8192
@@ -16,7 +33,7 @@ export LANG=en_US
 SNMPID=$$
 
 killed() {
-    rm -rf ${SENTINEL}
+    rm -f ${SENTINEL}
     killall -9 configesp 2>/dev/null
     sleep 1
     exit 255
@@ -29,11 +46,11 @@ echo $! > $PID_NAME
 wait
 
 while [ -e ${SENTINEL} ]; do
-        sleep 5
-        if [ -e ${SENTINEL} ]; then
-                nohup configesp 1>/dev/null 2>/dev/null &
+    sleep 5
+    if [ -e ${SENTINEL} ]; then
+        nohup configesp 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait
-        fi
+    fi
 done
 

+ 1 - 1
initfiles/bin/init_dafilesrv.in

@@ -34,6 +34,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="dafilesrv.sentinel"
+rm -f ${SENTINEL}
 
 killed(){
     rm -f ${SENTINEL}
@@ -42,7 +43,6 @@ killed(){
     exit 255
 }
 
-
 trap "killed" SIGINT SIGTERM SIGKILL
 dafilesrv -L $log &
 echo $! > $PID_NAME

+ 18 - 4
initfiles/bin/init_dali

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,22 +24,21 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="daserver.sentinel"
+rm -f ${SENTINEL}
 
 ulimit -n 8192
 
 killed(){
     dalistop .
-    rm -rf ${SENTINEL}
+    rm -f ${SENTINEL}
     exit 255
 }
 
-
 trap "killed" SIGINT SIGTERM SIGKILL
 daserver 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 
-
 while [ -e ${SENTINEL} ]; do
     sleep 5
     if [ -e ${SENTINEL} ]; then

+ 17 - 1
initfiles/bin/init_dfuserver

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +24,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="dfuserver.sentinel"
+rm -f ${SENTINEL}
 
 ulimit -c unlimited
 ulimit -n 8192

+ 2 - 1
initfiles/bin/init_eclagent.in

@@ -25,7 +25,8 @@ PID_NAME="$PID/`basename $PWD`.pid"
 INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
-export SENTINEL="eclagent.sentinel"
+export SENTINEL="agentexec.sentinel"
+rm -f ${SENTINEL}
 
 rm -f ${PID_DIR}/hthortemp/*
 

+ 17 - 1
initfiles/bin/init_eclccserver

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +24,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="eclccserver.sentinel"
+rm -f ${SENTINEL}
 
 killed() {
     PATH_PRE=`type -path hpcc_setenv`

+ 18 - 4
initfiles/bin/init_eclscheduler

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,21 +24,20 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="eclscheduler.sentinel"
+rm -f ${SENTINEL}
 
 killed(){
-    rm -rf ${SENTINEL}
+    rm -f ${SENTINEL}
     killall -9 eclscheduler
     sleep
     exit 255
 }
 
-
 trap "killed" SIGINT SIGTERM SIGKILL
 eclscheduler 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 
-
 while [ -e ${SENTINEL} ]; do
     sleep 5
     if [ -e ${SENTINEL} ]; then

+ 20 - 5
initfiles/bin/init_eclserver

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +24,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="eclserver.sentinel"
+rm -f ${SENTINEL}
 
 killed() {
     PATH_PRE=`type -path hpcc_setenv`
@@ -16,7 +32,6 @@ killed() {
     PID_NAME="$PID/`basename $PWD`.pid"
 
     if [ -e ${SENTINEL} ]; then
-
             rm -f ${SENTINEL}
             if [ -e ${PID_NAME} ]; then
                     pidwait_fn `cat ${PID_NAME}` 3
@@ -31,11 +46,11 @@ eclserver 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 if [ -e ${SENTINEL} ]; then
-        sleep 5
-        if [ -e ${SENTINEL} ]; then
+    sleep 5
+    if [ -e ${SENTINEL} ]; then
         eclserver 1>/dev/null 2>/dev/null & 
         echo $! > $PID_NAME
         wait
-        fi
+    fi
 fi
 

+ 19 - 6
initfiles/bin/init_esp

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +24,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="esp.sentinel"
+rm -f ${SENTINEL}
 
 ulimit -c unlimited
 ulimit -n 8192
@@ -17,7 +33,6 @@ SNMPID=$$
 
 killed() {
     rm -f ${SENTINEL}
-
     killall esp 1>/dev/null 2>/dev/null
     sleep 15
     killall -9 esp 1>/dev/null 2>/dev/null 
@@ -25,17 +40,15 @@ killed() {
     exit 255
 }
 
-
-
 trap "killed" SIGINT SIGTERM SIGKILL
 esp snmpid=$SNMPID 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 while [ -e ${SENTINEL} ]; do
     sleep 5
-        if [ -e ${SENTINEL} ]; then
+    if [ -e ${SENTINEL} ]; then
         esp snmpid=$SNMPID 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait
-        fi
+    fi
 done

+ 17 - 8
initfiles/bin/init_roxie

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -9,6 +24,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="roxie.sentinel"
+rm -f ${SENTINEL}
 
 if [ -n "$1" ]; then
     cd $1
@@ -32,12 +48,7 @@ killed() {
     if [ -n "$1" ]; then
         cd $1
     fi
-
-    . ./roxievars
-
     rm -f ${SENTINEL}
-
-    echo stopping roxie
     killall roxie
     sleep 5
     killall -9 roxie
@@ -45,9 +56,7 @@ killed() {
     exit 255
 }
 
-
 trap "killed" SIGINT SIGTERM SIGKILL
-# start it the first time - roxie controls the creation of the roxie.sentinel file
 nohup roxie topology=RoxieTopology.xml logfile=$logfilename restarts=$restarts stdlog=0 2>>$logfilename.stderr 1>>$logfilename.stdout & 
 echo $! > $PID_NAME 
 wait

+ 17 - 2
initfiles/bin/init_sasha

@@ -1,5 +1,20 @@
 #!/bin/bash
-## Copyright © 2011 HPCC Systems.  All rights reserved.
+################################################################################
+#    Copyright (C) 2011 HPCC Systems.
+#
+#    All rights reserved. This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+################################################################################
 
 PATH_PRE=`type -path hpcc_setenv`
 source ${PATH_PRE}
@@ -12,6 +27,7 @@ INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
 echo $$ > $INIT_PID_NAME
 
 export SENTINEL="saserver.sentinel"
+rm -f ${SENTINEL}
 
 ulimit -c unlimited
 ulimit -n 8192
@@ -19,7 +35,6 @@ ulimit -n 8192
 which_pidof
 
 killed() {
-
     rm -f ${SENTINEL}
     pid=`${PIDOF} saserver`
     if [ -n "$pid" ]; then