mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Don't kill container on backend restart commanded
This commit is contained in:
@@ -290,8 +290,6 @@ add_service "${SYSTEM_SERVICES}/start-backend.sh" "python3"
|
|||||||
# Useful for devcontainer debugging where individual services need to be debugged
|
# Useful for devcontainer debugging where individual services need to be debugged
|
||||||
if [ "${NETALERTX_DEBUG:-0}" -eq 1 ]; then
|
if [ "${NETALERTX_DEBUG:-0}" -eq 1 ]; then
|
||||||
echo "NETALERTX_DEBUG is set to 1, will not shut down other services if one fails."
|
echo "NETALERTX_DEBUG is set to 1, will not shut down other services if one fails."
|
||||||
wait
|
|
||||||
exit $?
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -316,10 +314,25 @@ while [ -n "${SERVICES}" ]; do
|
|||||||
if ! is_pid_active "${pid}"; then
|
if ! is_pid_active "${pid}"; then
|
||||||
wait "${pid}" 2>/dev/null
|
wait "${pid}" 2>/dev/null
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
|
# Handle intentional backend restart
|
||||||
|
if [ "${name}" = "python3" ] && [ -f "/tmp/backend_restart_pending" ]; then
|
||||||
|
echo "🔄 Backend restart requested via marker file."
|
||||||
|
rm -f "/tmp/backend_restart_pending"
|
||||||
|
remove_service "${pid}"
|
||||||
|
add_service "${SYSTEM_SERVICES}/start-backend.sh" "python3"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
FAILED_STATUS=$status
|
FAILED_STATUS=$status
|
||||||
FAILED_NAME="${name}"
|
FAILED_NAME="${name}"
|
||||||
remove_service "${pid}"
|
remove_service "${pid}"
|
||||||
handle_exit
|
|
||||||
|
if [ "${NETALERTX_DEBUG:-0}" -eq 1 ]; then
|
||||||
|
echo "⚠️ Service ${name} exited with status ${status}. Debug mode active - continuing."
|
||||||
|
else
|
||||||
|
handle_exit
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ export INSTALL_DIR=/app
|
|||||||
|
|
||||||
# Check if there are any entries with cron_restart_backend
|
# Check if there are any entries with cron_restart_backend
|
||||||
if grep -q "cron_restart_backend" "${LOG_EXECUTION_QUEUE}"; then
|
if grep -q "cron_restart_backend" "${LOG_EXECUTION_QUEUE}"; then
|
||||||
killall python3
|
echo "$(date): Restarting backend triggered by cron_restart_backend"
|
||||||
sleep 2
|
|
||||||
/services/start-backend.sh >/dev/null 2>&1 &
|
# Create marker for entrypoint.sh to restart the service instead of killing the container
|
||||||
|
touch /tmp/backend_restart_pending
|
||||||
|
|
||||||
|
killall python3 || echo "killall python3 failed or no process found"
|
||||||
|
|
||||||
# Remove all lines containing cron_restart_backend from the log file
|
# Remove all lines containing cron_restart_backend from the log file
|
||||||
# Atomic replacement with temp file
|
# Atomic replacement with temp file
|
||||||
|
|||||||
Reference in New Issue
Block a user