check_local_webservice.sh: no delay if running in an terminal.

This commit is contained in:
Christoph 2022-02-02 18:39:37 +01:00
parent 5899aef982
commit 15a4c23f15

View File

@ -176,9 +176,19 @@ TIME_OUT_MAX="$(expr ${TIME_OUT} + 5)"
# ------------- # -------------
# - Job is already running? # --- Check some prerequisites
# ------------- # -------------
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
LOGGING=true
else
terminal=false
LOGGING=false
fi
# - Stop here, if these give scripts are running # - Stop here, if these give scripts are running
# - # -
@ -191,9 +201,13 @@ if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then
# - This only makes sense if a fixed LOCK directory is used, otherwise the process list # - This only makes sense if a fixed LOCK directory is used, otherwise the process list
# - (and NOT the LOCK-directory) is used to look for scripts running in parallel. # - (and NOT the LOCK-directory) is used to look for scripts running in parallel.
# - # -
if [[ "$LOCK_DIR" = "/tmp/${script_name%%.*}.LOCK" ]]; then # - Skip delay if running in an terminal (from copnsole)
_shift="$(( $RANDOM % 10 + 1 ))" # -
sleep $(( $RANDOM % 25 + $_shift )) if ! $terminal ; then
if [[ "$LOCK_DIR" = "/tmp/${script_name%%.*}.LOCK" ]]; then
_shift="$(( $RANDOM % 10 + 1 ))"
sleep $(( $RANDOM % 25 + $_shift ))
fi
fi fi
_stop_running=false _stop_running=false
@ -237,6 +251,10 @@ if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then
fi # if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then fi # if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then
# -------------
# - Job is already running?
# -------------
# - If job already runs, stop execution.. # - If job already runs, stop execution..
# - # -
if mkdir "$LOCK_DIR" 2> /dev/null ; then if mkdir "$LOCK_DIR" 2> /dev/null ; then
@ -266,24 +284,10 @@ else
fi fi
# ------------- # -------------
# --- Check some prerequisites # --- Check some further prerequisites
# ------------- # -------------
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
LOGGING=true
else
terminal=false
LOGGING=false
fi
# - Systemd supported ? # - Systemd supported ?
# - # -
systemd=$(which systemd) systemd=$(which systemd)