harmonize background log messages

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-20 10:16:12 +02:00
parent 30a72eb853
commit 8f03835ccc

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.98-dev-39-g35d5e05
#### $$VERSION$$ v0.98-dev-61-g30a72eb
# will be automatically sourced from bashbot
@ -42,13 +42,13 @@ killproc() {
# $4 $5 parameters
start_back() {
local cmdfile; cmdfile="${DATADIR:-.}/$(procname "$1")$3-back.cmd"
printf "%s: Start background job CHAT=%s JOB=%s CMD=%s\n" "$(date)" "${1}" "${cmdfile##*/}" "${2} ${4} ${5}" >>"${UPDATELOG}"
printf '%s\n' "$1:$3:$2" >"${cmdfile}"
restart_back "$@"
}
restart_back() {
local fifo; fifo="${DATADIR:-.}/$(procname "$1" "back-$3-")"
kill_proc "$1" "back-$3-"
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-"
nohup bash -c "{ $2 \"$4\" \"$5\" \"${fifo}\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"; }" &>>"${fifo}.log" &
}
@ -60,8 +60,8 @@ start_proc() {
[ -z "$2" ] && return
[ -x "${2%% *}" ] || return 1
local fifo; fifo="${DATADIR:-.}/$(procname "$1")"
printf "%s: Start interacitve script CHAT=%s FIFO=%s CMD=%s\n" "$(date)" "${1}" "${fifo##*/}" "${2} ${3} ${4}" >>"${UPDATELOG}"
kill_proc "$1"
printf "%s: Start interacitve script CHAT=%s JOB=%s CMD=%s\n" "$(date)" "${1}" "${fifo##*/}" "${2} ${3} ${4}" >>"${UPDATELOG}"
check_proc "$1" && kill_proc "$1"
mkfifo "${fifo}"
nohup bash -c "{ $2 \"$4\" \"$5\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"
rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" &
@ -97,7 +97,7 @@ kill_proc() {
fifo="$(procname "$1" "$2")"
prid="$(proclist "${fifo}")"
fifo="${DATADIR:-.}/${fifo}"
printf "%s: Stop interacitve / background CHAT=%s FIFO/JOB=%s\n" "$(date)" "${1}" "${fifo##*/}" >>"${UPDATELOG}"
printf "%s: Stop interacitve / background CHAT=%s JOB=%s\n" "$(date)" "${1}" "${fifo##*/}" >>"${UPDATELOG}"
# shellcheck disable=SC2086
[ -n "${prid}" ] && kill ${prid}
[ -s "${fifo}.log" ] || rm -f "${fifo}.log"