fix Terminated message on stophook

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-06-03 12:03:10 +02:00
parent 45efa80699
commit 69b1871eea
2 changed files with 8 additions and 8 deletions

View File

@ -5,7 +5,7 @@
# #
# tested on: ubuntu, opensuse, debian # tested on: ubuntu, opensuse, debian
# #
#### $$VERSION$$ v1.51-dev-10-g12157b3 #### $$VERSION$$ v1.51-dev-22-g45efa80
# shellcheck disable=SC2009 # shellcheck disable=SC2009
# shellcheck disable=SC2181 # shellcheck disable=SC2181
# shellcheck disable=SC2250 # shellcheck disable=SC2250
@ -99,9 +99,9 @@ case "$1" in
'stophook') 'stophook')
[ "${stat}" != "hook" ] && printf "Warning, bot is not in webhook mode: %s\n" "${stat}" [ "${stat}" != "hook" ] && printf "Warning, bot is not in webhook mode: %s\n" "${stat}"
printf "Stopping bashbot webhook mode ... " printf "Stopping bashbot webhook mode ... "
KILLID="$(ps -f -u "${runas}" | grep "process_batch.sh --startbot" | sed -E 's/[^0-9]+([0-9]+).*/\1/')" KILLID="$(ps -f -u "${runas}" | grep "process_batch.sh --startbot" | sed -E 's/[^0-9]+([0-9]+).*/\1/' | tr -s "\r\n" " ")"
if [ -n "${KILLID}" ]; then if [ -n "${KILLID}" ]; then
$runcmd "kill $(printf "%s" "${KILLID}" | tr -s "\r\n" " " )" $runcmd "kill ${KILLID}; wait ${KILLID} 2>/dev/null"
sleep 1 sleep 1
fi fi
RETVAL=$? RETVAL=$?

View File

@ -4,7 +4,7 @@
# #
# FILE: bin/process_batch.sh # FILE: bin/process_batch.sh
# #
USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n] [file] [debug]' USAGE='process_batch.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n] [file] [debug]'
# #
# DESCRIPTION: processes last 10 telegram updates in file, one update per line # DESCRIPTION: processes last 10 telegram updates in file, one update per line
# #
@ -21,7 +21,7 @@ USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n]
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 27.02.2021 13:14 # CREATED: 27.02.2021 13:14
# #
#### $$VERSION$$ v1.50-13-g79fc511 #### $$VERSION$$ v1.51-dev-22-g45efa80
#=============================================================================== #===============================================================================
#### ####
@ -76,14 +76,14 @@ fi
# ready, do stuff here ----- # ready, do stuff here -----
# kill all sub processes on exit # kill all sub processes on exit
trap 'printf "%(%c)T: %s\n" -1 "Bot in '"${mode}"' mode stopped"; kill $(jobs -p) 2>/dev/null; send_normal_message "'"${BOTADMIN}"'" "Bot '"${BOTNAME} ${mode}"' stopped ..."' EXIT HUP QUIT trap 'printf "%(%c)T: %s\n" -1 "Bot in '"${mode}"' mode stopped"; kill $(jobs -p) 2>/dev/null; wait $(jobs -p) 2>/dev/null; send_normal_message "'"${BOTADMIN}"'" "Bot '"${BOTNAME} ${mode}"' stopped ..."' EXIT HUP QUIT
# wait after (first) update to avoid processing to many in parallel # wait after (first) update to avoid processing to many in parallel
UPDWAIT="0.5" UPDWAIT="0.5"
# use tail to read appended updates # use tail to read appended updates
# shellcheck disable=SC2086,SC2248 # shellcheck disable=SC2086,SC2248
tail ${follow} ${lines} "${file}" |\ tail ${follow} ${lines} "${file}" 2>/dev/null |\
while IFS="" read -r input while IFS="" read -r input 2>/dev/null
do do
# read json from stdin and convert update format # read json from stdin and convert update format
# replace any ID named BOTADMIN with ID of bot admin # replace any ID named BOTADMIN with ID of bot admin