Scanning Operational with monitoring

This commit is contained in:
Adam Outler
2025-09-30 22:01:03 -04:00
parent 044035ef62
commit 0cd1dc8987
15 changed files with 739 additions and 116 deletions

View File

@@ -1,6 +1,8 @@
#!/bin/bash
set -euo pipefail
echo "Starting backend..."
cd "${NETALERTX_APP}" || exit
cd "${NETALERTX_APP}" || exit 1
# Change user to netalertx
export PYTHONPATH="${NETALERTX_SERVER}:${NETALERTX_APP}"
@@ -9,5 +11,25 @@ if [ -f /services/config/python/backend-extra-launch-parameters ]; then
EXTRA_PARAMS=$(cat /services/config/python/backend-extra-launch-parameters)
fi
backend_pid=""
cleanup() {
status=$?
echo "Backend stopped! (exit ${status})"
}
forward_signal() {
if [[ -n "${backend_pid}" ]]; then
kill -TERM "${backend_pid}" 2>/dev/null || true
fi
}
trap cleanup EXIT
trap forward_signal INT TERM
# Start the backend, teeing stdout and stderr to log files and the container's console
python3 ${EXTRA_PARAMS} -m server > >(tee /app/log/stdout.log) 2> >(tee /app/log/stderr.log >&2)
python3 ${EXTRA_PARAMS} -m server > >(tee /app/log/stdout.log) 2> >(tee /app/log/stderr.log >&2) &
backend_pid=$!
wait "${backend_pid}"
exit $?