Skip to content

Commit

Permalink
Merge pull request #22 from Rareloop/feature/update-run-scheduler-to-…
Browse files Browse the repository at this point in the history
…be-configurable

Update run scheduler to be configurable
  • Loading branch information
ollwells authored Feb 20, 2024
2 parents effd6fd + c2ded0e commit cac2566
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions resources/scripts/php/run-scheduler.sh
Original file line number Diff line number Diff line change
@@ -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 * 60))

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

0 comments on commit cac2566

Please sign in to comment.