mirror of
https://github.com/troglobit/finit.git
synced 2026-10-10 16:52:39 +07:00
The slay script checks for common errors and gives some logs and status of Finit when something goes wrong. Helps detect issue #226 when the start-kill-service.sh test runs at 100000 laps. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
48 lines
757 B
Bash
Executable File
48 lines
757 B
Bash
Executable File
#!/bin/sh
|
|
|
|
nm=$1
|
|
|
|
# shellcheck disable=SC2046
|
|
getpid()
|
|
{
|
|
initctl status "$1" |awk '/PID :/{ print $3; }'
|
|
}
|
|
|
|
pid=$(getpid "$nm")
|
|
if [ -f oldpid ]; then
|
|
oldpid=$(cat oldpid)
|
|
if [ "$oldpid" = "$pid" ]; then
|
|
echo "Looks bad, wait for it ..."
|
|
sleep 3
|
|
pid=$(getpid "$nm")
|
|
if [ "$oldpid" = "$pid" ]; then
|
|
echo "Finit did not deregister old PID $oldpid vs $pid"
|
|
initctl status "$nm"
|
|
ps
|
|
echo "Reloading finit ..."
|
|
initctl reload
|
|
sleep 1
|
|
initctl status "$nm"
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ "$pid" -le 1 ]; then
|
|
sleep 3
|
|
pid=$(getpid "$nm")
|
|
if [ "$pid" -le 1 ]; then
|
|
echo "Got a bad PID: $pid, aborting ..."
|
|
ps
|
|
sleep 1
|
|
initctl status "$nm"
|
|
ps
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "$pid" > oldpid
|
|
|
|
#echo "PID $pid, kill -9 ..."
|
|
kill -9 "$pid"
|