Skip to content

Instantly share code, notes, and snippets.

@toocool
Created June 3, 2020 13:30
Show Gist options
  • Save toocool/308f0cd0c02c045d9f5b6642343c820c to your computer and use it in GitHub Desktop.
Save toocool/308f0cd0c02c045d9f5b6642343c820c to your computer and use it in GitHub Desktop.
Bash script to execute artisan based on the env
#!/usr/bin/env bash
set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
if [ "$role" = "app" ]; then
exec apache2-foreground
elif [ "$role" = "queue" ]; then
echo "Running the queue..."
php /var/www/html/artisan queue:work --memory=3800 --queue=bigjob --timeout=9600 --tries=1
elif [ "$role" = "scheduler" ]; then
while [ true ]
do
php /var/www/html/artisan schedule:run --verbose --no-interaction &
sleep 60
done
else
echo "Could not match the container role \"$role\""
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment