Browse Source

HPCC-19329 Allow parallel init for faster start/stop

Signed-off-by: Mark Kelly <mark.kelly@lexisnexisrisk.com>
Mark Kelly 7 years ago
parent
commit
27f0af29f4
2 changed files with 11 additions and 6 deletions
  1. 8 4
      initfiles/bash/etc/init.d/hpcc-init.in
  2. 3 2
      initfiles/bash/etc/init.d/init-functions

+ 8 - 4
initfiles/bash/etc/init.d/hpcc-init.in

@@ -278,10 +278,14 @@ if [ -z $arg ] || [ $# -ne 1 ]; then
     print_usage
 fi
 
-os=$(uname -s)
-if [[ -n "$HPCC_DEVELOPER" && "$os" = "Linux" && -f "${envfile}" ]] ; then
+thisos=$(uname -s)
+if [[ "$thisos" = "Linux" && -f "${envfile}" && -n "${component}" && \
+    "${DEBUG}" = "NO_DEBUG" && -z "$HPCC_NO_FLOCK" ]] ; then
     cfggenpre=(flock ${envfile})
-else
+fi
+
+# verbose output of all shell cmds to .debug file only if -d specified on cmdline
+if [[ "${DEBUG}" != "NO_DEBUG" ]] ; then
     log "Debug log written to $LOG_DIR/hpcc-init.debug"
     [ -e $LOG_DIR/hpcc-init.debug ] && rm -rf ${LOG_DIR}/hpcc-init.debug
     touch ${LOG_DIR}/hpcc-init.debug
@@ -291,7 +295,7 @@ else
     set -x
 fi
 
-if [ -z ${component} ]; then
+if [ -z "${component}" ]; then
     for (( i=0; i<=${compListLen}; i++ ));do
         component="$component ${compList[$i]}"
     done

+ 3 - 2
initfiles/bash/etc/init.d/init-functions

@@ -201,7 +201,7 @@ log_timeout_msg () {
 # general logging message for init scripts
 # expects $logfile to exist within the context of where it's called
 log() {
-  if [[ -z ${logfile+x} ]]; then
+  if [[ -z "${logfile}" ]]; then
     # logfile isn't set within the context of this function call
     return 1
   fi
@@ -209,7 +209,8 @@ log() {
   local msg=$@
   local header=$( date +%Y_%m_%d_%H_%M_%S )
   local header="${header}: "
-  (printf "%s%s\n" "$header" "$msg" >> $logfile) 2> /dev/null
+  local thispid=$$
+  (printf "%d %s%s\n" "$thispid" "$header" "$msg" >> $logfile) 2> /dev/null
   if [[ $? -ne 0 ]]; then
     echo "unable to write to ${logfile}" 1>&2
     return 1