better handling of restart jobs

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-22 14:10:36 +02:00
parent d52ea8c240
commit 4fe969766b
2 changed files with 5 additions and 3 deletions

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.98-dev-65-g25cc9a5 #### $$VERSION$$ v0.98-dev-66-gd52ea8c
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -994,7 +994,7 @@ if [ -z "${SOURCE}" ]; then
# internal options only for use from bashbot and developers # internal options only for use from bashbot and developers
case "$1" in case "$1" in
# update botname botname when starting only # update botname botname when starting only
"botname"|"start"*|"resume"*) "botname"|"start"*)
ME="$(getBotName)" ME="$(getBotName)"
if [ -n "${ME}" ]; then if [ -n "${ME}" ]; then
# ok we have a connection an got botname, save it # ok we have a connection an got botname, save it
@ -1130,6 +1130,7 @@ if [ -z "${SOURCE}" ]; then
# suspend, resume or kill backgrund jobs # suspend, resume or kill backgrund jobs
"suspendb"*|"resumeb"*|"killb"*) "suspendb"*|"resumeb"*|"killb"*)
_is_function job_control || { echo -e "${RED}Module background is not availible!${NC}"; exit 3; } _is_function job_control || { echo -e "${RED}Module background is not availible!${NC}"; exit 3; }
ME="$(getConfigKey "botname")"
job_control "$1" job_control "$1"
;; ;;
*) *)

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.98-dev-61-g30a72eb #### $$VERSION$$ v0.98-dev-66-gd52ea8c
# will be automatically sourced from bashbot # will be automatically sourced from bashbot
@ -50,6 +50,7 @@ restart_back() {
printf "%s: Start background job CHAT=%s JOB=%s CMD=%s\n" "$(date)" "${1}" "${fifo##*/}" "${2} ${4} ${5}" >>"${UPDATELOG}" printf "%s: Start background job CHAT=%s JOB=%s CMD=%s\n" "$(date)" "${1}" "${fifo##*/}" "${2} ${4} ${5}" >>"${UPDATELOG}"
check_back "$1" "$3" && kill_proc "$1" "back-$3-" check_back "$1" "$3" && kill_proc "$1" "back-$3-"
nohup bash -c "{ $2 \"$4\" \"$5\" \"${fifo}\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"; }" &>>"${fifo}.log" & nohup bash -c "{ $2 \"$4\" \"$5\" \"${fifo}\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"; }" &>>"${fifo}.log" &
sleep 0.5 # give bg job some time to init
} }