From 7e78d8d67f455a25e9aaf982d5d7ca9e3086a916 Mon Sep 17 00:00:00 2001 From: Ollie Wells Date: Tue, 20 Feb 2024 10:41:52 +0000 Subject: [PATCH 1/2] Update run scheduler to be configurable --- resources/scripts/php/run-scheduler.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/resources/scripts/php/run-scheduler.sh b/resources/scripts/php/run-scheduler.sh index dd7c7ef..4a73f9b 100755 --- a/resources/scripts/php/run-scheduler.sh +++ b/resources/scripts/php/run-scheduler.sh @@ -1,6 +1,26 @@ #!/bin/bash + +# Get the value of the ENV_VAR environment variable or use a default value +SCHEDULE_MINUTES=${INTERVAL_MINUTES} +COMMAND=${CRON_COMMAND} + +if [[ "" == "${COMMAND}" ]]; then + # Default to the laravel command for backward compatibility + COMMAND="php /var/www/artisan schedule:run --verbose --no-interaction" +fi + +if [[ "" == "${SCHEDULE_MINUTES}" ]]; then + # Default to every minute + SCHEDULE_MINUTES=1 +fi + +# Calculate seconds +SCHEDULE_SECONDS=$((SCHEDULE_MINUTES * 1)) + +echo "Running every ${SCHEDULE_MINUTES} minutes: ${COMMAND}" + while true do - php /var/www/artisan schedule:run --verbose --no-interaction & - sleep 60 + ${COMMAND} & + sleep ${SCHEDULE_SECONDS} done From c2ded0ec32f423903685956a1b9ee3be9609a7f7 Mon Sep 17 00:00:00 2001 From: Ollie Wells Date: Tue, 20 Feb 2024 10:45:17 +0000 Subject: [PATCH 2/2] Update seconds --- resources/scripts/php/run-scheduler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/scripts/php/run-scheduler.sh b/resources/scripts/php/run-scheduler.sh index 4a73f9b..71d63f0 100755 --- a/resources/scripts/php/run-scheduler.sh +++ b/resources/scripts/php/run-scheduler.sh @@ -15,7 +15,7 @@ if [[ "" == "${SCHEDULE_MINUTES}" ]]; then fi # Calculate seconds -SCHEDULE_SECONDS=$((SCHEDULE_MINUTES * 1)) +SCHEDULE_SECONDS=$((SCHEDULE_MINUTES * 60)) echo "Running every ${SCHEDULE_MINUTES} minutes: ${COMMAND}"