|
@@ -251,26 +251,10 @@ set_environmentvars() {
|
|
|
## use default of "DEFAULT"
|
|
|
##
|
|
|
SECTION=${SECTION:-DEFAULT}
|
|
|
- DEBUG=${DEBUG:-NO_DEBUG}
|
|
|
|
|
|
cfg.parser ${HPCC_CONFIG}
|
|
|
cfg.section.${SECTION}
|
|
|
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "\$runtime=$runtime"
|
|
|
- echo "\$path=$path"
|
|
|
- echo "\$configs=$configs"
|
|
|
- echo "\$configsbackup=$configsbackup"
|
|
|
- echo "\$user=$user"
|
|
|
- echo "\$lock=$lock"
|
|
|
- echo "\$pid=$pid"
|
|
|
- echo "\$log=$log"
|
|
|
- echo "\$environment=$environment"
|
|
|
- echo "\$interface=$interface"
|
|
|
- echo "\$autodetectipscript=$autodetectipscript"
|
|
|
- echo
|
|
|
- fi
|
|
|
-
|
|
|
if [ -n "${umask}" ]; then
|
|
|
umask $umask
|
|
|
fi
|
|
@@ -298,15 +282,10 @@ configGenCmd() {
|
|
|
|
|
|
# Creating logfiles for component
|
|
|
logDir=$log/${compName}
|
|
|
- logFile=$log/${compName}/init_${compName}.log
|
|
|
|
|
|
configcmd="${configgen_path}/configgen -env ${envfile} -od ${runtime} -id ${componentFile} -c ${compName}"
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo $configcmd
|
|
|
- else
|
|
|
- echo $configcmd >> $logFile
|
|
|
- fi
|
|
|
- su ${user} -c "$configcmd" >> $logFile 2>&1
|
|
|
+ log "$configcmd"
|
|
|
+ su ${user} -c "$configcmd" 2>/dev/null
|
|
|
}
|
|
|
|
|
|
createRuntime() {
|
|
@@ -337,31 +316,23 @@ createRuntime() {
|
|
|
# Creating Component Specific directories
|
|
|
# Creating pidfile specific directory and changing its owner permissions
|
|
|
if [ ! -d "$pid/$compName" ]; then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "Creating Pidfile directory"
|
|
|
- fi
|
|
|
+ log "Creating Pidfile Directory $pid/$compName"
|
|
|
createDir "$pid/$compName"
|
|
|
fi
|
|
|
|
|
|
if [ ! -d "$lock/$compName" ]; then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "Creating lockfile directory"
|
|
|
- fi
|
|
|
+ log "Creating Lockfile Directory $lock/$compName"
|
|
|
createDir "$lock/$compName"
|
|
|
fi
|
|
|
|
|
|
if [ ! -d "$log/$compName" ]; then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "Creating log directory"
|
|
|
- fi
|
|
|
+ log "Creating Log Directory $log/$compName"
|
|
|
createDir "$log/$compName"
|
|
|
fi
|
|
|
|
|
|
# Creating runtime specific directory and changing its owner permissions
|
|
|
if [ ! -d $compPath ]; then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "Creating Runtime Directory for $compName"
|
|
|
- fi
|
|
|
+ log "Creating Runtime Directory $compPath"
|
|
|
createDir "$compPath"
|
|
|
fi
|
|
|
|
|
@@ -394,17 +365,14 @@ start_dafilesrv() {
|
|
|
/etc/init.d/dafilesrv status 1>/dev/null 2>/dev/null
|
|
|
if [ $? -ne 0 ];then
|
|
|
#Dafilesrv is not running so start it , before starting cleanup the lock and pid file.
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- log_failure_msg "Pid or lock file exists, but process is not running"
|
|
|
- fi
|
|
|
cleanupRuntimeEnvironment
|
|
|
-
|
|
|
noStatusCheck=1
|
|
|
/etc/init.d/dafilesrv setup 1>/dev/null 2>/dev/null
|
|
|
startCmd ${compName} ${noStatusCheck}
|
|
|
return $?
|
|
|
else
|
|
|
- printf "Starting %-21s" "$compName.... "
|
|
|
+ log "Component $compName already started ..."
|
|
|
+ printf "Starting %-21s" "$compName ..."
|
|
|
log_success_msg "Already started"
|
|
|
return 0
|
|
|
fi
|
|
@@ -412,18 +380,14 @@ start_dafilesrv() {
|
|
|
|
|
|
startCmd() {
|
|
|
noStatusCheck=$2
|
|
|
- printf "Starting %-21s" "$compName.... "
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "compName=$compName compPath=$compPath compProcessName=$compType"
|
|
|
- fi
|
|
|
+ printf "Starting %-21s" "$compName ..."
|
|
|
+ log "compType = $compType"
|
|
|
|
|
|
# use less heap when threaded
|
|
|
export MALLOC_ARENA_MAX=8
|
|
|
|
|
|
# Creating logfiles for component
|
|
|
logDir=$log/${compName}
|
|
|
- logFile=$log/${compName}/init_${compName}.log
|
|
|
-
|
|
|
|
|
|
if [ ${noStatusCheck} -ne 1 ]; then
|
|
|
check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 1
|
|
@@ -434,6 +398,7 @@ startCmd() {
|
|
|
fi
|
|
|
if [ ${RCSTART} -eq 0 ]; then
|
|
|
#Since component is already started but current script is failed till returning 0
|
|
|
+ log "$compName ---> already started"
|
|
|
log_success_msg "Already Started"
|
|
|
return ${RCSTART}
|
|
|
fi
|
|
@@ -469,29 +434,24 @@ startCmd() {
|
|
|
fi
|
|
|
|
|
|
EXEC_COMMAND="${bin_path}/init_${compType} "
|
|
|
- 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 "
|
|
|
- echo $logCommand >> $logFile
|
|
|
+ startcmd="${START_STOP_DAEMON} -S -p ${pid}/init_${compName}.pid -c ${user}:${group} -d ${compPath} ${UMASK_ARG} -m -x ${EXEC_COMMAND} -b"
|
|
|
|
|
|
+ log "${startcmd}"
|
|
|
|
|
|
# Creating a Lock
|
|
|
lockPath=${lock}/${compName}
|
|
|
if [ ! -d $lockPath ]; then
|
|
|
- mkdir -p $lockPath >> $logFile 2>&1
|
|
|
+ mkdir -p $lockPath >>/dev/null 2>&1
|
|
|
fi
|
|
|
chown -c $user:$group $lockPath >> /dev/null 2>&1
|
|
|
lock ${lock}/${compName}/${compName}.lock
|
|
|
|
|
|
if [ $__lockCreated -eq 0 ]; then
|
|
|
+ log "Cannot create the lock file. File locked by subsystem"
|
|
|
log_failure_msg "Cannot create the lock file, File locked by subsystem"
|
|
|
return 3
|
|
|
fi
|
|
|
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo $startcmd
|
|
|
- fi
|
|
|
eval $startcmd
|
|
|
|
|
|
|
|
@@ -516,6 +476,7 @@ startCmd() {
|
|
|
COMPONENT_HAS_STARTED=1
|
|
|
else
|
|
|
if [ ${COMPONENT_HAS_STARTED} -eq 1 ]; then
|
|
|
+ log "${compName} failed to start cleanly"
|
|
|
log_failure_msg "${compName} failed to start cleanly"
|
|
|
return 0;
|
|
|
fi
|
|
@@ -525,6 +486,7 @@ startCmd() {
|
|
|
|
|
|
if [ ${WAITTIME} -eq 0 ]; then
|
|
|
log_timeout_msg
|
|
|
+ log "${compName} has timed out, but may still be starting"
|
|
|
fi
|
|
|
|
|
|
chmod 644 ${envfile}
|
|
@@ -543,21 +505,15 @@ stop_component() {
|
|
|
check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 0
|
|
|
RCSTOP=$?
|
|
|
if [ $RCSTOP -ne 0 ];then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- log_success_msg "Process already stopped :: check_status code is ${RCSTOP}"
|
|
|
- else
|
|
|
- log_success_msg "Already stopped"
|
|
|
- fi
|
|
|
- cleanup_component
|
|
|
- cleanupRuntimeEnvironment
|
|
|
- return 0
|
|
|
+ log "Already stopped"
|
|
|
+ log_success_msg "Already stopped"
|
|
|
+ cleanup_component
|
|
|
+ cleanupRuntimeEnvironment
|
|
|
+ return 0
|
|
|
fi
|
|
|
|
|
|
stopcmd="${START_STOP_DAEMON} -K -p ${PIDPATH} >> tmp.txt 2>&1"
|
|
|
-
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "$stopcmd"
|
|
|
- fi
|
|
|
+ log "$stopcmd"
|
|
|
|
|
|
eval $stopcmd
|
|
|
|
|
@@ -598,27 +554,15 @@ stop_component() {
|
|
|
|
|
|
|
|
|
start_component() {
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "comp_return = $comp_return"
|
|
|
- echo "compName = $compName compPath = $compPath "
|
|
|
- echo "path = $PATH"
|
|
|
- fi
|
|
|
-
|
|
|
|
|
|
- # Creating logfiles for component
|
|
|
+ # Creating logdirs for component
|
|
|
logDir=$log/${compName}
|
|
|
- logFile=$log/${compName}/init_${compName}.log
|
|
|
|
|
|
if [ ! -d $logDir ]; then
|
|
|
mkdir -p $logDir >> tmp.txt 2>&1
|
|
|
chown -c $user:$group $logDir >> /dev/null 2>&1
|
|
|
fi
|
|
|
|
|
|
- if [ ! -f $logFile ]; then
|
|
|
- touch $logFile >> tmp.txt 2>&1
|
|
|
- chown -c $user:$group $logFile >> /dev/null 2>&1
|
|
|
- fi
|
|
|
-
|
|
|
# Creating Runtime
|
|
|
createRuntime $compName $compPath
|
|
|
|
|
@@ -628,7 +572,7 @@ start_component() {
|
|
|
|
|
|
if [ ${runSetupOnly} -ne 1 ]
|
|
|
then
|
|
|
- cd ${compPath} > $logFile 2>&1
|
|
|
+ cd ${compPath} >>/dev/null 2>&1
|
|
|
startCmd ${compName} 0
|
|
|
STAT=$?
|
|
|
fi
|
|
@@ -637,27 +581,29 @@ start_component() {
|
|
|
|
|
|
restart_component() {
|
|
|
if strstr "${compType}" "dafilesrv" ;then
|
|
|
- /etc/init.d/dafilesrv status 1>/dev/null 2>/dev/null
|
|
|
- if [ $? -eq 0 ];then
|
|
|
- /etc/init.d/dafilesrv stop 2>/dev/null
|
|
|
- else
|
|
|
- echo "Component $compName was not running. Will start it now for you ...."
|
|
|
- cleanupRuntimeEnvironment
|
|
|
- fi
|
|
|
- /etc/init.d/dafilesrv start 2>/dev/null
|
|
|
+ /etc/init.d/dafilesrv status 1>/dev/null 2>/dev/null
|
|
|
+ if [ $? -eq 0 ];then
|
|
|
+ /etc/init.d/dafilesrv stop 2>/dev/null
|
|
|
+ else
|
|
|
+ log "$compName ---> Stopped. Now Starting ..."
|
|
|
+ echo "Component $compName was not running. Will start it now for you ..."
|
|
|
+ cleanupRuntimeEnvironment
|
|
|
+ fi
|
|
|
+ /etc/init.d/dafilesrv start 2>/dev/null
|
|
|
else
|
|
|
- check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 1
|
|
|
- RCRESTART=$?
|
|
|
- if [ $RCRESTART -ne 0 ];then
|
|
|
- echo "Component $compName was not running. Will start it now for you ...."
|
|
|
- cleanupRuntimeEnvironment
|
|
|
- else
|
|
|
- stop_component ${compName}
|
|
|
- fi
|
|
|
- start_component $compName
|
|
|
- check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 1
|
|
|
- RCRESTART=$?
|
|
|
- return $RCRESTART
|
|
|
+ check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 1
|
|
|
+ RCRESTART=$?
|
|
|
+ if [ $RCRESTART -ne 0 ];then
|
|
|
+ log "$compName ---> Stopped. Now Starting ..."
|
|
|
+ echo "Component $compName was not running. Will start it now for you ..."
|
|
|
+ cleanupRuntimeEnvironment
|
|
|
+ else
|
|
|
+ stop_component ${compName}
|
|
|
+ fi
|
|
|
+ start_component $compName
|
|
|
+ check_status ${PIDPATH} ${LOCKPATH} ${COMPPIDPATH} 1
|
|
|
+ RCRESTART=$?
|
|
|
+ return $RCRESTART
|
|
|
fi
|
|
|
}
|
|
|
|
|
@@ -666,9 +612,11 @@ status_component() {
|
|
|
RCSTATUS=$?
|
|
|
getPid ${COMPPIDPATH}
|
|
|
if [ ${RCSTATUS} -ne 0 ];then
|
|
|
+ log "${compName} ---> Stopped"
|
|
|
printf "%-15s is stopped" "$compName"
|
|
|
else
|
|
|
- printf "%-15s ( pid %8s ) is running..." "${compName}" "${__pidValue}"
|
|
|
+ log "${compName} ---> Running ( pid ${__pidValue} )"
|
|
|
+ printf "%-15s ( pid %8s ) is running ..." "${compName}" "${__pidValue}"
|
|
|
fi
|
|
|
echo ""
|
|
|
return ${RCSTATUS}
|
|
@@ -1001,23 +949,17 @@ cleanup_component() {
|
|
|
WAITTIME=`expr ${WAITTIME} - 1`
|
|
|
kill -0 -$pgid &> /dev/null
|
|
|
if [ $? -ne 0 ];then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ];then
|
|
|
- echo "${compName} orphans cleaned up"
|
|
|
- fi
|
|
|
+ log "${compName} orphans cleaned up"
|
|
|
RUNNING=0
|
|
|
break;
|
|
|
else
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "Waiting for ${compName} orphans to cleanup gracefully"
|
|
|
- fi
|
|
|
+ log "Waiting for ${compName} orphans to cleanup gracefully"
|
|
|
sleep 1
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
if [[ ${RUNNING} -eq 1 ]]; then
|
|
|
- if [ ${DEBUG} != "NO_DEBUG" ]; then
|
|
|
- echo "sending SIGKILL to ${compName} orphans"
|
|
|
- fi
|
|
|
+ log "sending SIGKILL to ${compName} orphans"
|
|
|
kill -9 -$pgid
|
|
|
fi
|
|
|
fi
|