Disable SGE queue only if sge_execd is absent

This commit is contained in:
Jeremy Gardais 2021-11-24 07:35:44 +01:00
parent 2340ced9b8
commit 1279e28e83
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 34 additions and 12 deletions

View File

@ -329,6 +329,32 @@ procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on t
return "${return_proc_running}" return "${return_proc_running}"
}
# }}}
is_proc_absent() { # {{{
local_proc_pattern="${1}"
## Proc is absent by default
return_proc_absent="0"
local_count_proc_pattern="$(pgrep -f -- "${local_proc_pattern}" | wc -l)"
case "${local_count_proc_pattern}" in
0 ) ## No procs related to this pattern are running
return_proc_absent="0"
;;
* ) ## At least one proc seems running
return_proc_absent="1"
;;
esac
## Simple debug message to valid current variables
debug_message "is_proc_absent \
procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on the current host: ${RED}${local_count_proc_pattern}${COLOR_DEBUG}."
return "${return_proc_absent}"
} }
# }}} # }}}
is_file_present() { # {{{ is_file_present() { # {{{
@ -527,22 +553,18 @@ main() { # {{{
## If we need to watch for processes ## If we need to watch for processes
if [ "${CHECK_PROCESS}" -eq "0" ]; then if [ "${CHECK_PROCESS}" -eq "0" ]; then
## Ensure the SGE queue(s) are really disable without creation of any flag file
sh "${sge_disable_host_queue_script}" --force
## Wait few seconds
sleep "${sleep_delay}"
## If nothing related to SGE is currently running {{{ ## If nothing related to SGE is currently running {{{
### First ensure that SGE queue(s) are really disable without creation of any flag file
### Wait few seconds
### Try to start the SGE execd systemd service ### Try to start the SGE execd systemd service
### Exit with error if the service can't start ### Wait few seconds
is_proc_running "${sge_proc_pattern}" \ is_proc_absent "${sge_proc_pattern}" \
|| systemctl --quiet start sge_execd.service > /dev/null 2>&1 \ && sh "${sge_disable_host_queue_script}" --force \
|| exit 4 && sleep "${sleep_delay}" \
&& systemctl --quiet start sge_execd.service > /dev/null 2>&1 \
&& sleep "${sleep_delay}"
## }}} ## }}}
## Wait few seconds
sleep "${sleep_delay}"
fi fi
## If we need to watch for upgrades ## If we need to watch for upgrades