mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-25 08:47:34 +00:00
harmonize background log messages
This commit is contained in:
parent
30a72eb853
commit
8f03835ccc
@ -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-39-g35d5e05
|
#### $$VERSION$$ v0.98-dev-61-g30a72eb
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -42,13 +42,13 @@ killproc() {
|
|||||||
# $4 $5 parameters
|
# $4 $5 parameters
|
||||||
start_back() {
|
start_back() {
|
||||||
local cmdfile; cmdfile="${DATADIR:-.}/$(procname "$1")$3-back.cmd"
|
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}"
|
printf '%s\n' "$1:$3:$2" >"${cmdfile}"
|
||||||
restart_back "$@"
|
restart_back "$@"
|
||||||
}
|
}
|
||||||
restart_back() {
|
restart_back() {
|
||||||
local fifo; fifo="${DATADIR:-.}/$(procname "$1" "back-$3-")"
|
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" &
|
nohup bash -c "{ $2 \"$4\" \"$5\" \"${fifo}\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"; }" &>>"${fifo}.log" &
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ start_proc() {
|
|||||||
[ -z "$2" ] && return
|
[ -z "$2" ] && return
|
||||||
[ -x "${2%% *}" ] || return 1
|
[ -x "${2%% *}" ] || return 1
|
||||||
local fifo; fifo="${DATADIR:-.}/$(procname "$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}"
|
printf "%s: Start interacitve script CHAT=%s JOB=%s CMD=%s\n" "$(date)" "${1}" "${fifo##*/}" "${2} ${3} ${4}" >>"${UPDATELOG}"
|
||||||
kill_proc "$1"
|
check_proc "$1" && kill_proc "$1"
|
||||||
mkfifo "${fifo}"
|
mkfifo "${fifo}"
|
||||||
nohup bash -c "{ $2 \"$4\" \"$5\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"
|
nohup bash -c "{ $2 \"$4\" \"$5\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\"
|
||||||
rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" &
|
rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" &
|
||||||
@ -97,7 +97,7 @@ kill_proc() {
|
|||||||
fifo="$(procname "$1" "$2")"
|
fifo="$(procname "$1" "$2")"
|
||||||
prid="$(proclist "${fifo}")"
|
prid="$(proclist "${fifo}")"
|
||||||
fifo="${DATADIR:-.}/${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
|
# shellcheck disable=SC2086
|
||||||
[ -n "${prid}" ] && kill ${prid}
|
[ -n "${prid}" ] && kill ${prid}
|
||||||
[ -s "${fifo}.log" ] || rm -f "${fifo}.log"
|
[ -s "${fifo}.log" ] || rm -f "${fifo}.log"
|
||||||
|
Loading…
Reference in New Issue
Block a user