Commit e348dd54 authored by nextime's avatar nextime

Fix watchdog PID file race condition

- Watchdog scripts now wait for PID file creation before exiting
- Reduced init script sleep time from 3 to 1 second
- Prevents 'Watchdog failed to start properly' timing issues
- Fixed both wssshd and wssshc watchdog/init scripts
parent 50a1e7af
......@@ -189,7 +189,18 @@ case "$1" in
exit 1
fi
main &
echo "Watchdog started"
# Wait for PID file to be created (max 5 seconds)
local count=0
while [ $count -lt 10 ] && [ ! -f "$WATCHDOG_PID_FILE" ]; do
sleep 0.5
count=$((count + 1))
done
if [ -f "$WATCHDOG_PID_FILE" ]; then
echo "Watchdog started"
else
echo "Watchdog failed to create PID file"
exit 1
fi
;;
stop)
if [ -f "$WATCHDOG_PID_FILE" ]; then
......
......@@ -157,8 +157,8 @@ start() {
local retval=$?
if [ $retval -eq 0 ]; then
# Wait a moment for the watchdog to start
sleep 3
# Wait a moment for the watchdog to start (reduced since watchdog now waits for PID file)
sleep 1
# Check if watchdog is running
if [ -f "$WATCHDOG_PIDFILE" ] && kill -0 "$(cat "$WATCHDOG_PIDFILE")" 2>/dev/null; then
......
......@@ -100,8 +100,8 @@ start() {
local retval=$?
if [ $retval -eq 0 ]; then
# Wait a moment for the watchdog to start
sleep 3
# Wait a moment for the watchdog to start (reduced since watchdog now waits for PID file)
sleep 1
# Check if watchdog is running
if [ -f "$WATCHDOG_PIDFILE" ] && kill -0 "$(cat "$WATCHDOG_PIDFILE")" 2>/dev/null; then
......
......@@ -189,7 +189,18 @@ case "$1" in
exit 1
fi
main &
echo "Watchdog started"
# Wait for PID file to be created (max 5 seconds)
local count=0
while [ $count -lt 10 ] && [ ! -f "$WATCHDOG_PID_FILE" ]; do
sleep 0.5
count=$((count + 1))
done
if [ -f "$WATCHDOG_PID_FILE" ]; then
echo "Watchdog started"
else
echo "Watchdog failed to create PID file"
exit 1
fi
;;
stop)
if [ -f "$WATCHDOG_PID_FILE" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment