From 5857976d0d529efab3ec31e6af9c041b66557bf3 Mon Sep 17 00:00:00 2001 From: Mitch Talmadge Date: Mon, 30 Oct 2023 13:22:58 -0600 Subject: [PATCH] Monitor AMP and run scheduled tasks --- entrypoint/main.sh | 1 + entrypoint/routines.sh | 8 ++++++++ entrypoint/utils.sh | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/entrypoint/main.sh b/entrypoint/main.sh index 8366319..96efe73 100644 --- a/entrypoint/main.sh +++ b/entrypoint/main.sh @@ -50,5 +50,6 @@ trap "stop_amp" SIGTERM # Sleep echo "AMP is now running. Logs can be viewed through AMP web UI or at ampdata/instances/Main/AMP_Logs" +monitor_amp & tail -f /dev/null & wait $! diff --git a/entrypoint/routines.sh b/entrypoint/routines.sh index e964f16..8b1ced8 100644 --- a/entrypoint/routines.sh +++ b/entrypoint/routines.sh @@ -100,6 +100,14 @@ handle_error() { exit 1 } +monitor_amp() { + # Periodically process pending tasks (e.g. upgrade, reboots, ...) + while true; do + run_amp_command_silently "ProcessPendingTasks" + sleep 5 # The UI's restart timeout is 10 seconds, so let's be safe. + done +} + run_startup_script() { # Users may provide their own startup script for installing dependencies, etc. STARTUP_SCRIPT="/home/amp/scripts/startup.sh" diff --git a/entrypoint/utils.sh b/entrypoint/utils.sh index 79b4e77..773429d 100644 --- a/entrypoint/utils.sh +++ b/entrypoint/utils.sh @@ -10,4 +10,8 @@ does_main_instance_exist() { run_amp_command() { su ${APP_USER} --command "ampinstmgr $1" +} + +run_amp_command_silently() { + su ${APP_USER} --command "ampinstmgr --silent $1" } \ No newline at end of file