mirror of
https://github.com/openappsec/openappsec.git
synced 2025-06-28 16:41:02 +03:00
Fix Watchdog restarts (#319)
* don't exit * fix restarting agent * fix watchdog restarts
This commit is contained in:
parent
4dacd7d009
commit
bc1eac9d39
@ -98,25 +98,16 @@ if [ -f "$FILE" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
touch /etc/cp/watchdog/wd.startup
|
touch /etc/cp/watchdog/wd.startup
|
||||||
|
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
||||||
|
active_watchdog_pid=$!
|
||||||
while true; do
|
while true; do
|
||||||
if [ -z "$init" ]; then
|
if [ -f /tmp/restart_watchdog ]; then
|
||||||
init=true
|
|
||||||
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
|
||||||
sleep 5
|
|
||||||
active_watchdog_pid=$(pgrep -f -x -o "/bin/(bash|sh) /etc/cp/watchdog/cp-nano-watchdog")
|
|
||||||
fi
|
|
||||||
|
|
||||||
current_watchdog_pid=$(pgrep -f -x -o "/bin/(bash|sh) /etc/cp/watchdog/cp-nano-watchdog")
|
|
||||||
if [ ! -f /tmp/restart_watchdog ] && [ "$current_watchdog_pid" != "$active_watchdog_pid" ]; then
|
|
||||||
echo "Error: Watchdog exited abnormally"
|
|
||||||
exit 1
|
|
||||||
elif [ -f /tmp/restart_watchdog ]; then
|
|
||||||
rm -f /tmp/restart_watchdog
|
rm -f /tmp/restart_watchdog
|
||||||
kill -9 "$(pgrep -f -x -o "/bin/(bash|sh) /etc/cp/watchdog/cp-nano-watchdog")"
|
kill -9 ${active_watchdog_pid}
|
||||||
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
fi
|
||||||
sleep 5
|
if [ ! "$(ps -f | grep cp-nano-watchdog | grep ${active_watchdog_pid})" ]; then
|
||||||
active_watchdog_pid=$(pgrep -f -x -o "/bin/(bash|sh) /etc/cp/watchdog/cp-nano-watchdog")
|
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
||||||
|
active_watchdog_pid=$!
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user