From f56e2b067ca44c0eefb1b423bcfd2aca87e8b485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 18 Nov 2021 12:11:04 +0100 Subject: [PATCH] Add a delay after the start of sge_execd --- cluster/sge.enable.host.queue.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cluster/sge.enable.host.queue.sh b/cluster/sge.enable.host.queue.sh index 544a1ed..0f8500b 100755 --- a/cluster/sge.enable.host.queue.sh +++ b/cluster/sge.enable.host.queue.sh @@ -22,6 +22,9 @@ readonly MACO_TMP_URGENT_FILE="${MACO_LOCAL_DIR}/.maco.urgent.upgrade" # Maco status file readonly MACO_STATUS_FILE="/var/fr.univ-rennes1.ipr.maco.machinestate.txt" +# Default sleep delay +readonly SLEEP_DELAY_DEFAULT="15" + ## Colors readonly PURPLE='\033[1;35m' readonly RED='\033[0;31m' @@ -32,7 +35,7 @@ readonly COLOR_DEBUG="${PURPLE}" usage() { # {{{ 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), if no pending upgrades (Maco, APT) are present, @@ -46,6 +49,9 @@ EXAMPLES : ${PROGNAME} 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 : -d,--debug Enable debug messages. @@ -64,6 +70,10 @@ OPTIONS : -q,--quiet 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 } @@ -91,11 +101,18 @@ message() { # {{{ # }}} define_vars() { # {{{ - ## If sge_hostname wasn't defined + ## If sge_hostname wasn't defined {{{ if [ -z "${sge_hostname}" ]; then ## Use local host for sge_hostname sge_hostname="$(hostname -f)" 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 is_current_host "${sge_hostname}" ; then @@ -509,6 +526,9 @@ main() { # {{{ is_proc_running "${sge_proc_pattern}" \ || systemctl --quiet start sge_execd.service > /dev/null 2>&1 \ || exit 4 + + ## Wait some seconds + sleep "${sleep_delay}" fi ## If we need to watch for upgrades