Add a delay after the start of sge_execd

This commit is contained in:
Jeremy Gardais 2021-11-18 12:11:04 +01:00
parent 900cc0611d
commit f56e2b067c
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 22 additions and 2 deletions

View File

@ -22,6 +22,9 @@ readonly MACO_TMP_URGENT_FILE="${MACO_LOCAL_DIR}/.maco.urgent.upgrade"
# Maco status file # Maco status file
readonly MACO_STATUS_FILE="/var/fr.univ-rennes1.ipr.maco.machinestate.txt" readonly MACO_STATUS_FILE="/var/fr.univ-rennes1.ipr.maco.machinestate.txt"
# Default sleep delay
readonly SLEEP_DELAY_DEFAULT="15"
## Colors ## Colors
readonly PURPLE='\033[1;35m' readonly PURPLE='\033[1;35m'
readonly RED='\033[0;31m' readonly RED='\033[0;31m'
@ -32,7 +35,7 @@ readonly COLOR_DEBUG="${PURPLE}"
usage() { # {{{ usage() { # {{{
cat <<- EOF cat <<- EOF
usage: $PROGNAME [--help] [-d|-f|-h|-q] [hostname] usage: $PROGNAME [--help] [-d|-f|-h|-q|-s] [hostname]
Try to enable all SGE queues of the current host (default), Try to enable all SGE queues of the current host (default),
if no pending upgrades (Maco, APT) are present, if no pending upgrades (Maco, APT) are present,
@ -46,6 +49,9 @@ EXAMPLES:
${PROGNAME} marvin.domain.tld ${PROGNAME} marvin.domain.tld
${PROGNAME} -h marvin.domain.tld ${PROGNAME} -h marvin.domain.tld
- Wait 30 seconds after the start of sge_execd (default: ${SLEEP_DELAY_DEFAULT})
${PROGNAME} -s 30
OPTIONS: OPTIONS:
-d,--debug -d,--debug
Enable debug messages. Enable debug messages.
@ -64,6 +70,10 @@ OPTIONS:
-q,--quiet -q,--quiet
Disable messages on standard output (except for error). Disable messages on standard output (except for error).
-s,--sleep
Set a different delay to wait after the sge_execd start
(default: ${SLEEP_DELAY_DEFAULT}).
EOF EOF
} }
@ -91,11 +101,18 @@ message() { # {{{
# }}} # }}}
define_vars() { # {{{ define_vars() { # {{{
## If sge_hostname wasn't defined ## If sge_hostname wasn't defined {{{
if [ -z "${sge_hostname}" ]; then if [ -z "${sge_hostname}" ]; then
## Use local host for sge_hostname ## Use local host for sge_hostname
sge_hostname="$(hostname -f)" sge_hostname="$(hostname -f)"
fi fi
## }}}
## If sleep_delay wasn't defined (argument) {{{
if [ -z "${sleep_delay}" ]; then
## Use default value
readonly sleep_delay="${SLEEP_DELAY_DEFAULT}"
fi
## }}}
## If the host to manage is the current one ## If the host to manage is the current one
if is_current_host "${sge_hostname}" ; then if is_current_host "${sge_hostname}" ; then
@ -509,6 +526,9 @@ main() { # {{{
is_proc_running "${sge_proc_pattern}" \ is_proc_running "${sge_proc_pattern}" \
|| systemctl --quiet start sge_execd.service > /dev/null 2>&1 \ || systemctl --quiet start sge_execd.service > /dev/null 2>&1 \
|| exit 4 || exit 4
## Wait some seconds
sleep "${sleep_delay}"
fi fi
## If we need to watch for upgrades ## If we need to watch for upgrades