Add specific system callbacks to future proof priority order
This commit is contained in:
parent
d02f5d27ca
commit
85694429ee
35
rowbot
35
rowbot
|
@ -155,13 +155,17 @@ get_option trigger \`
|
|||
get_option dev yes
|
||||
|
||||
###
|
||||
# bootup sequence
|
||||
# bootup/shutdown sequence
|
||||
###
|
||||
|
||||
on_first_001_bootup() {
|
||||
on_sys_first_001_bootup() {
|
||||
log_info "rowbot's pid is %d" "$$"
|
||||
}
|
||||
|
||||
on_sys_exit_999_bootup() {
|
||||
log_info "There’s a lot of beauty in ordinary things. Isn’t that kind of the point?"
|
||||
}
|
||||
|
||||
###
|
||||
# logger
|
||||
###
|
||||
|
@ -200,7 +204,7 @@ log_has_level() {
|
|||
return 1
|
||||
}
|
||||
|
||||
on_init_001_log() {
|
||||
on_sys_init_001_log() {
|
||||
declare -gA log_levels=( [debug]=1 [info]=2 [warn]=3 [error]=4 )
|
||||
get_option log-level info
|
||||
|
||||
|
@ -223,8 +227,9 @@ on_init_001_log() {
|
|||
fi
|
||||
}
|
||||
|
||||
on_exit_zzz_log() {
|
||||
on_sys_exit_999_log() {
|
||||
if [[ -v log_fd ]] && (( log_fd != 1 )); then
|
||||
log_debug "shutting logger down"
|
||||
exec {log_fd}>&-
|
||||
fi
|
||||
}
|
||||
|
@ -249,7 +254,7 @@ net_send() {
|
|||
log_debug "sending line: %s" "$fmt"
|
||||
}
|
||||
|
||||
on_init_002_net() {
|
||||
on_sys_init_002_net() {
|
||||
get_option server irc.libera.chat
|
||||
get_option tls no
|
||||
|
||||
|
@ -261,8 +266,8 @@ on_init_002_net() {
|
|||
fi
|
||||
}
|
||||
|
||||
on_first_002_net() {
|
||||
local irc_sock conn_args
|
||||
on_sys_first_002_net() {
|
||||
local conn_args
|
||||
|
||||
if [[ ${config[tls]} = no ]]; then
|
||||
log_info "rowbot is connecting to irc://%s:%s" "${config[server]}" "${config[port]}"
|
||||
|
@ -297,13 +302,23 @@ on_first_002_net() {
|
|||
fi
|
||||
}
|
||||
|
||||
on_sys_exit_998_net() {
|
||||
if [[ ${config[tls]} = no ]]; then
|
||||
log_info "rowbot is closing the connection to irc://%s:%s" "${config[server]}" "${config[port]}"
|
||||
exec {irc_sock}>&-
|
||||
else
|
||||
log_info "rowbot is closing the connection to ircs://%s:%s" "${config[server]}" "${config[port]}"
|
||||
rm -rf -- "$sock_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
###
|
||||
# cleanup
|
||||
###
|
||||
|
||||
cleanup() {
|
||||
log_info "There’s a lot of beauty in ordinary things. Isn’t that kind of the point?"
|
||||
run_callbacks on_exit_
|
||||
run_callbacks on_sys_exit_
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
@ -314,6 +329,7 @@ trap cleanup EXIT
|
|||
|
||||
reload_config() {
|
||||
local setting setting_name
|
||||
run_callbacks on_sys_before_
|
||||
run_callbacks on_before_
|
||||
|
||||
for setting in "${!config[@]}"; do
|
||||
|
@ -335,10 +351,13 @@ trap reload_hup HUP
|
|||
# initialization sequence
|
||||
###
|
||||
|
||||
run_callbacks on_sys_init_
|
||||
run_callbacks on_init_
|
||||
|
||||
if is_reloaded; then
|
||||
run_callbacks on_sys_after_
|
||||
run_callbacks on_after_
|
||||
else
|
||||
run_callbacks on_sys_first_
|
||||
run_callbacks on_first_
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue