mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
Convert from crond to supercronic
This commit is contained in:
5
install/production-filesystem/build/init-cron.sh
Normal file
5
install/production-filesystem/build/init-cron.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
#!/bin/bash
|
||||
echo "Initializing cron..."
|
||||
# Placeholder for cron initialization commands
|
||||
echo "cron initialized."
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo "Initializing crond..."
|
||||
#Future crond initializations can go here.
|
||||
echo "crond initialized."
|
||||
@@ -274,7 +274,7 @@ trap on_signal INT TERM
|
||||
# Only start crond scheduler on Alpine (non-Debian) environments
|
||||
# Debian typically uses systemd or other schedulers
|
||||
if [ "${ENVIRONMENT:-}" ] && [ "${ENVIRONMENT:-}" != "debian" ]; then
|
||||
add_service "/services/start-crond.sh" "crond"
|
||||
add_service "/services/start-cron.sh" "supercronic"
|
||||
fi
|
||||
|
||||
# Start core frontend and backend services
|
||||
|
||||
2
install/production-filesystem/services/config/crond/netalertx → install/production-filesystem/services/config/cron/crontab
Executable file → Normal file
2
install/production-filesystem/services/config/crond/netalertx → install/production-filesystem/services/config/cron/crontab
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
# Every minute check for cron jobs
|
||||
* * * * * /services/scripts/cron_script.sh
|
||||
# Update vendors 4x/d
|
||||
0 */6 * * * /services/scripts/update_vendors.sh
|
||||
0 */6 * * * /services/scripts/update_vendors.sh
|
||||
@@ -7,10 +7,10 @@ export INSTALL_DIR=/app
|
||||
if grep -q "cron_restart_backend" "${LOG_EXECUTION_QUEUE}"; then
|
||||
killall python3
|
||||
sleep 2
|
||||
/services/start-backend.sh &
|
||||
/services/start-backend.sh >/dev/null 2>&1 &
|
||||
|
||||
# Remove all lines containing cron_restart_backend from the log file
|
||||
# Atomic replacement with temp file
|
||||
grep -v "cron_restart_backend" "${LOG_EXECUTION_QUEUE}" > "${LOG_EXECUTION_QUEUE}.tmp" && \
|
||||
mv "${LOG_EXECUTION_QUEUE}.tmp" "${LOG_EXECUTION_QUEUE}"
|
||||
grep -v "cron_restart_backend" "${LOG_EXECUTION_QUEUE}" > "${LOG_EXECUTION_QUEUE}.tmp"
|
||||
mv "${LOG_EXECUTION_QUEUE}.tmp" "${LOG_EXECUTION_QUEUE}"
|
||||
fi
|
||||
|
||||
@@ -6,7 +6,7 @@ crond_pid=""
|
||||
|
||||
cleanup() {
|
||||
status=$?
|
||||
echo "Crond stopped! (exit ${status})"
|
||||
echo "Supercronic stopped! (exit ${status})"
|
||||
}
|
||||
|
||||
forward_signal() {
|
||||
@@ -23,11 +23,16 @@ done
|
||||
trap cleanup EXIT
|
||||
trap forward_signal INT TERM
|
||||
|
||||
echo "Starting /usr/sbin/crond -c \"${SYSTEM_SERVICES_CROND}\" -f -L \"${LOG_CROND}\" >>\"${LOG_CROND}\" 2>&1 &"
|
||||
CRON_OPTS="--quiet"
|
||||
if [ "${NETALERTX_DEBUG:-0}" -eq 1 ]; then
|
||||
CRON_OPTS="--debug"
|
||||
fi
|
||||
|
||||
/usr/sbin/crond -c "${SYSTEM_SERVICES_CROND}" -f -L "${LOG_CROND}" >>"${LOG_CROND}" 2>&1 &
|
||||
echo "Starting supercronic ${CRON_OPTS} \"${SYSTEM_SERVICES_CONFIG_CRON}/crontab\" >>\"${LOG_CRON}\" 2>&1 &"
|
||||
|
||||
supercronic ${CRON_OPTS} "${SYSTEM_SERVICES_CONFIG_CRON}/crontab" >>"${LOG_CRON}" 2>&1 &
|
||||
crond_pid=$!
|
||||
|
||||
wait "${crond_pid}"; status=$?
|
||||
echo -ne " done"
|
||||
exit ${status}
|
||||
exit ${status}
|
||||
Reference in New Issue
Block a user