Fix the alarm reload code

This commit is contained in:
Nick Chambers 2021-06-19 14:34:36 -05:00
parent 0042338b2a
commit 46ca97edfb
1 changed files with 16 additions and 7 deletions

23
rowbot
View File

@ -119,9 +119,7 @@ fi
###
cleanup() {
if [[ -v tls_pid || $tls = no ]]; then
exec {in_sock}>&- {out_sock}>&- {log}>&-
fi
debug "cleaning up rowbot"
if [[ -v tls_pid ]]; then
kill "$tls_pid"
@ -129,11 +127,22 @@ cleanup() {
fi
if [[ -v ping_pid ]]; then
debug "cleaning up alarm in %d" "$BASHPID"
kill "$ping_pid"
fi
if [[ -v tls_pid || $tls = no ]]; then
exec {in_sock}>&- {out_sock}>&-
if (( log != 1 )); then
{log}>&-
fi
fi
}
trap cleanup EXIT
if (( BASHPID == $$ )); then
trap cleanup EXIT
fi
alarm-handler() {
ping "row your bot gently down the stream"
@ -155,7 +164,7 @@ if [[ $reload = yes ]]; then
trigger=$TRIGGER dev=$DEV level=$LOG_LEVEL
registered=$REGISTERED
debug "doing a reload. pid is %d" "$$"
debug "doing a reload. pid is %d" "$BASHPID"
if [[ -v KEEP_TRYING ]]; then
keep_trying=$KEEP_TRYING desired_nick=$DESIRED
@ -649,7 +658,7 @@ hook_post_PRIVMSG_control_panel() {
fi
if [[ -v ping_pid ]]; then
export PING_pid=$ping_pid
export PING_PID=$ping_pid
fi
privmsg "$to" "reloading..."
@ -719,7 +728,7 @@ if [[ $reload = yes ]]; then
privmsg "$RELOAD_TO" done.
else
registered=no
info "rowbot's pid is %d" "$$"
info "rowbot's pid is %d" "$BASHPID"
nick "$nick"
user "$ident" "$realname"
fi