1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-04 22:21:55 +03:00
systemd/test/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh
Daniel Black a327431bd1 core: add EXTEND_TIMEOUT_USEC={usec} - prevent timeouts in startup/runtime/shutdown (#7214)
With Type=notify services, EXTEND_TIMEOUT_USEC= messages will delay any startup/
runtime/shutdown timeouts.

A service that hasn't timed out, i.e, start time < TimeStartSec,
runtime < RuntimeMaxSec and stop time < TimeoutStopSec, may by sending
EXTEND_TIMEOUT_USEC=, allow the service to continue beyond the limit for
the execution phase (i.e TimeStartSec, RunTimeMaxSec and TimeoutStopSec).

EXTEND_TIMEOUT_USEC= must continue to be sent (in the same way as
WATCHDOG=1) within the time interval specified to continue to reprevent
the timeout from occuring.

Watchdog timeouts are also extended if a EXTEND_TIMEOUT_USEC is greater
than the remaining time on the watchdog counter.

Fixes #5868.
2017-12-14 12:17:43 +01:00

71 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -x
set -e
set -o pipefail
# sleep interval (seconds)
sleep_interval=1
# extend_timeout_interval second(s)
extend_timeout_interval=1
# number of sleep_intervals before READY=1
start_intervals=10
# number of sleep_intervals before exiting
stop_intervals=10
# run intervals, number of sleep_intervals to run
run_intervals=7
# service name
SERVICE=unknown
while [ $# -gt 0 ];
do
eval ${1%=*}=${1#*=}
shift
done
# We convert to usec
extend_timeout_interval=$(( $extend_timeout_interval * 1000000 ))
trap "{ touch /${SERVICE}.terminated; exit 1; }" SIGTERM SIGABRT
rm -f /${SERVICE}.*
touch /${SERVICE}.startfail
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [ $start_intervals -gt 0 ]
do
sleep $sleep_interval
start_intervals=$(( $start_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done
systemd-notify --ready --status="Waiting for your request"
touch /${SERVICE}.runtimefail
rm /${SERVICE}.startfail
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [ $run_intervals -gt 0 ]
do
sleep $sleep_interval
run_intervals=$(( $run_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done
systemd-notify STOPPING=1
touch /${SERVICE}.stopfail
rm /${SERVICE}.runtimefail
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
while [ $stop_intervals -gt 0 ]
do
sleep $sleep_interval
stop_intervals=$(( $stop_intervals - 1 ))
systemd-notify EXTEND_TIMEOUT_USEC=$extend_timeout_interval
done
touch /${SERVICE}.success
rm /${SERVICE}.stopfail
exit 0