瀏覽代碼

Merge pull request #7274 from Michael-Gardner/HPCC-13489

HPCC-13489 Make a 1 to 1 relationship between init_compname and init process

Reviewed-By: Jake Smith <jake.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 年之前
父節點
當前提交
ee32bdd41b

+ 6 - 7
initfiles/bash/etc/init.d/hpcc_common.in

@@ -282,7 +282,7 @@ set_componentvars() {
     comp.getByName ${compName}
     compPath=`echo $comp_return | cut -d ' ' -f 2 | cut -d '=' -f 2 `
     compType=`echo $comp_return | cut -d ' ' -f 1 | cut -d '=' -f 2 `
-    PIDPATH=${pid}/${compName}_init.pid
+    PIDPATH=${pid}/init_${compName}.pid
     LOCKPATH=${lock}/$compName/$compName.lock
     COMPPIDPATH=${pid}/${compName}.pid
 }
@@ -298,7 +298,7 @@ configGenCmd() {
 
     # Creating logfiles for component
     logDir=$log/${compName}
-    logFile=$log/${compName}/${compName}_init.log
+    logFile=$log/${compName}/init_${compName}.log
 
     configcmd="${configgen_path}/configgen -env ${envfile} -od ${runtime} -id ${componentFile} -c ${compName}"
     if [ ${DEBUG} != "NO_DEBUG" ]; then
@@ -385,9 +385,8 @@ createRuntime() {
 # cleanup all standard files made during runtime
 cleanupRuntimeEnvironment() {
     unlock ${lock}/${compName}/${compName}.lock
-    removePid ${pid}/${compName}_init.pid
-    removePid ${pid}/${compName}.pid
     removePid ${pid}/init_${compName}.pid
+    removePid ${pid}/${compName}.pid
 }
 
 
@@ -423,7 +422,7 @@ startCmd() {
 
     # Creating logfiles for component
     logDir=$log/${compName}
-    logFile=$log/${compName}/${compName}_init.log
+    logFile=$log/${compName}/init_${compName}.log
 
 
     if [ ${noStatusCheck} -ne 1 ]; then
@@ -470,7 +469,7 @@ startCmd() {
     fi
 
     EXEC_COMMAND="${bin_path}/init_${compType} "
-    startcmd="${START_STOP_DAEMON} -S -p ${pid}/${compName}_init.pid -c ${user}:${group} -d ${compPath} ${UMASK_ARG} -m -x ${EXEC_COMMAND} -b  >>${logFile} 2>&1"
+    startcmd="${START_STOP_DAEMON} -S -p ${pid}/init_${compName}.pid -c ${user}:${group} -d ${compPath} ${UMASK_ARG} -m -x ${EXEC_COMMAND} -b  >>${logFile} 2>&1"
 
     issueTime=`date`
     logCommand="COMMAND:: $startcmd  ::Issued at $issueTime "
@@ -609,7 +608,7 @@ start_component() {
 
     # Creating logfiles for component
     logDir=$log/${compName}
-    logFile=$log/${compName}/${compName}_init.log
+    logFile=$log/${compName}/init_${compName}.log
 
     if [ ! -d $logDir ]; then
         mkdir -p $logDir >> tmp.txt 2>&1

+ 6 - 12
initfiles/bin/init_configesp

@@ -16,21 +16,15 @@
 ################################################################################
 
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="configesp.sentinel"
 rm -f ${SENTINEL}
 
-
-
-SNMPID=$$
-
-killed() {
+killed()
+{
     kill_process ${PID_NAME} configesp 3 ${SENTINEL}
     exit 255
 }
@@ -42,9 +36,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         nohup configesp 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait

+ 9 - 13
initfiles/bin/init_dafilesrv.in

@@ -22,17 +22,12 @@ if [ -z $1 ]; then
 else
         log=$1
 fi
-
 shift
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INSTANCE_NAME="`basename $PWD`"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
+COMP_NAME="$(basename $PWD)"
 
 # this must match jsocket hard limit
 export handlelimit=32768
@@ -40,7 +35,8 @@ export handlelimit=32768
 export SENTINEL="dafilesrv.sentinel"
 rm -f ${SENTINEL}
 
-killed(){
+killed()
+{
     kill_process ${PID_NAME} dafilesrv 3 ${SENTINEL}
     exit 255
 }
@@ -49,15 +45,15 @@ ulimit -c unlimited
 ulimit -n $handlelimit
 
 trap "killed" SIGINT SIGTERM SIGKILL
-dafilesrv -L $log -I ${INSTANCE_NAME} &
+dafilesrv -L $log -I ${COMP_NAME} &
 echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
-        dafilesrv -L $log -I ${INSTANCE_NAME} &
+    if [[ -e ${SENTINEL} ]]; then
+        dafilesrv -L $log -I ${COMP_NAME} &
         echo $! > $PID_NAME
         wait
         rm $PID_NAME

+ 6 - 11
initfiles/bin/init_dali

@@ -15,20 +15,15 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="daserver.sentinel"
 rm -f ${SENTINEL}
 
-
-
-
-killed(){
+killed()
+{
     dalistop .
     kill_process ${PID_NAME} daserver 3 ${SENTINEL}
     exit 255
@@ -40,9 +35,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         daserver 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait

+ 6 - 12
initfiles/bin/init_dfuserver

@@ -15,21 +15,15 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="dfuserver.sentinel"
 rm -f ${SENTINEL}
 
-
-
-
-
-killed() {
+killed()
+{
     dfuserver stop=1
     sleep 5
     kill_process ${PID_NAME} dfuserver 3 ${SENTINEL}
@@ -43,9 +37,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         dfuserver 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait

+ 6 - 10
initfiles/bin/init_eclagent.in

@@ -17,35 +17,31 @@
 
 ###<REPLACE>###
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="agentexec.sentinel"
 rm -f ${SENTINEL}
 
 rm -f ${PID_DIR}/hthortemp/*
 
-killed (){
+killed ()
+{
     kill_process ${PID_NAME} agentexec 3 ${SENTINEL}
     exit 255
 }
 
-
 trap "killed" SIGINT SIGTERM SIGKILL
 
-
 agentexec 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 1
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         agentexec 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait

+ 6 - 10
initfiles/bin/init_eclccserver

@@ -15,19 +15,15 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="eclccserver.sentinel"
 rm -f ${SENTINEL}
 
-
-
-killed() {
+killed()
+{
     kill_process ${PID_NAME} eclccserver 3 ${SENTINEL}
     exit 255
 }
@@ -38,9 +34,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         eclccserver 1>/dev/null 2>/dev/null & 
         echo $! > $PID_NAME
         wait

+ 6 - 8
initfiles/bin/init_eclscheduler

@@ -15,17 +15,15 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="eclscheduler.sentinel"
 rm -f ${SENTINEL}
 
-killed(){
+killed()
+{
     kill_process ${PID_NAME} eclscheduler 3 ${SENTINEL}
     exit 255
 }
@@ -36,9 +34,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         eclscheduler 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait

+ 4 - 9
initfiles/bin/init_esp

@@ -15,18 +15,13 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="esp.sentinel"
 rm -f ${SENTINEL}
 
-
-
 SNMPID=$$
 
 killed() {
@@ -39,9 +34,9 @@ esp snmpid=$SNMPID 1>/dev/null 2>/dev/null &
 echo $! > $PID_NAME
 wait
 rm $PID_NAME
-while [ -e ${SENTINEL} ]; do
+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

+ 8 - 10
initfiles/bin/init_roxie

@@ -15,12 +15,9 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
-
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
+PID_NAME="$PID/$(basename $PWD).pid"
 
 export SENTINEL="roxie.sentinel"
 rm -f ${SENTINEL}
@@ -29,11 +26,11 @@ if [ -n "$1" ]; then
     cd $1
 fi
 
-. ./roxievars
+source ./roxievars
 
 if [ -n "$2" ]; then
     logfilename=$2
-else    
+else
     logfilename="`date +%m_%d_%Y_%H_%M_%S`"
 fi
 
@@ -43,8 +40,9 @@ export restarts=0
 ulimit -c unlimited
 ulimit -n $NUM_ROXIE_HANDLES
 
-killed() {
-    if [ -n "$1" ]; then
+killed()
+{
+    if [[ -n "$1" ]]; then
         cd $1
     fi
     kill_process ${PID_NAME} roxie 3 ${SENTINEL}
@@ -58,7 +56,7 @@ wait
 rm $PID_NAME
 
 # Automatically restart roxie when it dies
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     export restarts=$(($restarts+1))
     echo Restarting $restarts >> $logfilename.stderr
     echo Restarting $restarts >> $logfilename.stdout

+ 8 - 10
initfiles/bin/init_roxie_cluster

@@ -15,28 +15,26 @@
 #    limitations under the License.
 ################################################################################
 
-. ./roxievars
-
-killed () {
-    . ./roxievars
+source ./roxievars
 
+killed ()
+{
     echo --------------------------
     echo stopping roxie
-    if [ "$useSSH" = "true" ]; then
+    if [[ "$useSSH" = "true" ]]; then
        frunssh slaves "PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH init_stopccd $roxiedir" -i:$SSHidentityfile -u:$SSHusername -pe:$SSHpassword -t:$SSHtimeout -a:$SSHretries 2>&1 | egrep -v "no process killed"
-    else        
+    else
        frunagent @slaves start "PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH init_stopccd $roxiedir"
     fi
-    sleep 10 
+    sleep 10
     exit 255
-
 }
 
 trap "killed" SIGINT SIGTERM SIGKILL
 logfile="`date +%m_%d_%Y_%H_%M_%S`"
-if [ "$useSSH" = "true" ]; then
+if [[ "$useSSH" = "true" ]]; then
   frunssh slaves "/bin/sh -c 'PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH init_startccd $roxiedir $logfile 1>/dev/null 2>/dev/null &'" -i:$SSHidentityfile -u:$SSHusername -pe:$SSHpassword -t:$SSHtimeout -a:$SSHretries 2>&1
 else
-  frunagent @slaves start "PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH init_startccd $roxiedir $logfile 1>/dev/null 2>/dev/null &"  
+  frunagent @slaves start "PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH init_startccd $roxiedir $logfile 1>/dev/null 2>/dev/null &"
 fi
 

+ 7 - 29
initfiles/bin/init_sasha

@@ -15,40 +15,18 @@
 #    limitations under the License.
 ################################################################################
 
-PATH_PRE=`type -path hpcc_setenv`
+PATH_PRE=$(type -path hpcc_setenv)
 source ${PATH_PRE}
-PID_NAME="$PID/`basename $PWD`.pid"
+PID_NAME="$PID/$(basename $PWD).pid"
 
-INSTALL_DIR=`dirname ${PATH_PRE}`/..
+INSTALL_DIR="$(dirname ${PATH_PRE})/.."
 source  ${INSTALL_DIR}/etc/init.d/hpcc_common
 
-INIT_PID_NAME="$PID/init_`basename $PWD`.pid"
-echo $$ > $INIT_PID_NAME
-
 export SENTINEL="saserver.sentinel"
 rm -f ${SENTINEL}
 
-
-
-
-which_pidof
-
-killed() {
-    pid=`${PIDOF} saserver`
-    if [ -n "$pid" ]; then
-        sasha server=. action=stop
-        I=1
-        while [ -n "$pid" ] && [ $I -lt 30 ]; do
-            echo "Waiting for saserver to stop"
-            sleep 2
-            pid=`${PIDOF} saserver`
-            let I=I+1
-        
-        done
-        if [ -n "$pid" ]; then
-            kill -9 $pid
-        fi
-    fi
+killed()
+{
     kill_process ${PID_NAME} saserver 3 ${SENTINEL}
     exit 255
 }
@@ -59,9 +37,9 @@ echo $! > $PID_NAME
 wait
 rm $PID_NAME
 
-while [ -e ${SENTINEL} ]; do
+while [[ -e ${SENTINEL} ]]; do
     sleep 5
-    if [ -e ${SENTINEL} ]; then
+    if [[ -e ${SENTINEL} ]]; then
         saserver 1>/dev/null 2>/dev/null &
         echo $! > $PID_NAME
         wait