Reload resources on SIGHUP

This commit is contained in:
Nick Chambers 2021-06-20 02:19:39 -05:00
parent 8e294b4880
commit 104b83964b
1 changed files with 28 additions and 2 deletions

30
rowbot
View File

@ -106,6 +106,8 @@ while (( $# )); do
shift
done
prog_args=( "$@" )
###
# default config
##
@ -125,7 +127,7 @@ for file do
# shellcheck disable=SC1090
. "$file" # ha, dot file
else
die 'could not locate config file %s' "$file"
die "could not locate config file %s" "$file"
fi
done
@ -203,7 +205,7 @@ if [[ $reload = yes ]]; then
fi
###
# process management
# process/resource management
###
cleanup() {
@ -244,6 +246,30 @@ alarm-handler() {
trap alarm-handler ALRM
config-reload() {
local file
info "received HUP signal"
for file in "${prog_args[@]}"; do
if [[ -f $file ]]; then
debug "loading config file %s" "$file"
# These files are provided dynamically at run-time.
# shellcheck disable=SC1090
. "$file"
else
die "could not locate config file %s" "$file"
fi
done
if (( log_fd != 1 )); then
debug "closing and re-opening log"
exec {log_fd}>&-
exec {log_fd}>"$log"
fi
}
trap config-reload HUP
###
# net code
###