summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2018-09-25 02:13:13 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2018-10-02 19:02:25 -0400
commit39525411b8da45a35e958378cb8dec316918d142 (patch)
tree096be68224530f632fc081d45d5776655b489a44
parent89d7feaec16c19908052801075196d4207ac9f03 (diff)
be more verbose when killing/stopping/dying
-rwxr-xr-xpbot26
-rwxr-xr-xpbot-ng_fixer9
2 files changed, 24 insertions, 11 deletions
diff --git a/pbot b/pbot
index a619241..ec4d91b 100755
--- a/pbot
+++ b/pbot
@@ -2,25 +2,29 @@
if [[ "${1}" == 'start' ]]
then
- declare -a pids
-
cd /home/pbot
./envbot &
- pids[0]=$!
+ envbot_pid=$!
./pbot-ng_fixer &
- pids[1]=$!
+ pbotng_fixer_pid=$!
./labs_change_detector &
- pids[2]=$!
+ labs_change_detector_pid=$!
function closedown
{
- for pid in ${pids[@]}
- do
- kill $pid
- done
+ echo "[pbot]: received SIGINT/SIGTERM"
+
+ echo "[pbot]: killing envbot($envbot_pid)"
+ kill $envbot_pid
+
+ echo "[pbot]: killing pbot-ng_fixer($pbotng_fixer_pid)"
+ kill $pbotng_fixer_pid
+
+ echo "[pbot]: killing labs_change_detector($labs_change_detector_pid)"
+ kill $labs_change_detector_pid
exit
}
@@ -33,13 +37,17 @@ then
done
elif [[ "${1}" == 'stop' ]]
then
+ echo "[pbot]: stopping per 'stop' command"
+
while true
do
pid=$(pgrep -u pbot | head -1)
if [[ -n "${pid}" ]]
then
+ echo "[pbot]: killing '$(ps -p ${pid} -o comm=)'(${pid})"
kill ${pid} &>/dev/null
+ sleep 1
else
exit
fi
diff --git a/pbot-ng_fixer b/pbot-ng_fixer
index b7ae075..b040727 100755
--- a/pbot-ng_fixer
+++ b/pbot-ng_fixer
@@ -8,11 +8,16 @@ do
# pbot is dead.
if [[ -z $(find logs/ -iname 'raw.log' -mmin -30) ]]
then
+ echo "[pbot-ng_fixer]: restarting pbot due to inactivity"
+
# Kill all pbot processes
- while read -r line
+ while read -r pid
do
# If it's not the pid of this process then kill it.
- [[ "${line}" != "$$" ]] && kill "${line}" &>/dev/null
+ [[ "${pid}" != "$$" ]] || continue
+
+ echo "[pbot-ng_fixer]: killing '$(ps -p ${pid} -o comm=)'(${pid})"
+ kill "${pid}" &>/dev/null
done < <( pgrep -u pbot )
# Start pbot