2024-01-06 12:15:51 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2022-06-18 10:31:47 +02:00
|
|
|
echo ""
|
|
|
|
|
echo "***********************************************************"
|
2023-12-09 18:25:28 +01:00
|
|
|
echo " Starting LARAVEL PHP-FPM Container "
|
2022-06-18 10:31:47 +02:00
|
|
|
echo "***********************************************************"
|
|
|
|
|
|
|
|
|
|
set -e
|
2024-01-06 12:15:51 +01:00
|
|
|
info() {
|
|
|
|
|
{ set +x; } 2> /dev/null
|
|
|
|
|
echo '[INFO] ' "$@"
|
|
|
|
|
}
|
|
|
|
|
warning() {
|
|
|
|
|
{ set +x; } 2> /dev/null
|
|
|
|
|
echo '[WARNING] ' "$@"
|
|
|
|
|
}
|
|
|
|
|
fatal() {
|
|
|
|
|
{ set +x; } 2> /dev/null
|
|
|
|
|
echo '[ERROR] ' "$@" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
2022-06-21 10:04:42 +02:00
|
|
|
## Check if the artisan file exists
|
2022-09-05 14:41:20 +02:00
|
|
|
if [ -f /var/www/html/artisan ]; then
|
2024-01-06 12:15:51 +01:00
|
|
|
info "Artisan file found, creating laravel supervisor config..."
|
2022-06-21 10:04:42 +02:00
|
|
|
##Create Laravel Scheduler process
|
|
|
|
|
TASK=/etc/supervisor/conf.d/laravel-worker.conf
|
|
|
|
|
touch $TASK
|
|
|
|
|
cat > "$TASK" <<EOF
|
|
|
|
|
[program:Laravel-scheduler]
|
|
|
|
|
process_name=%(program_name)s_%(process_num)02d
|
2022-09-05 14:41:20 +02:00
|
|
|
command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
2022-06-21 10:04:42 +02:00
|
|
|
autostart=true
|
|
|
|
|
autorestart=true
|
|
|
|
|
numprocs=1
|
2024-01-06 12:15:51 +01:00
|
|
|
user=$USER_NAME
|
2022-06-21 10:04:42 +02:00
|
|
|
stdout_logfile=/var/log/laravel_scheduler.out.log
|
|
|
|
|
redirect_stderr=true
|
|
|
|
|
|
|
|
|
|
[program:Laravel-worker]
|
|
|
|
|
process_name=%(program_name)s_%(process_num)02d
|
2022-09-05 14:41:20 +02:00
|
|
|
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
|
2022-06-21 10:04:42 +02:00
|
|
|
autostart=true
|
|
|
|
|
autorestart=true
|
2022-06-21 20:01:57 +02:00
|
|
|
numprocs=$LARAVEL_PROCS_NUMBER
|
2024-01-06 12:15:51 +01:00
|
|
|
user=$USER_NAME
|
2022-06-21 10:04:42 +02:00
|
|
|
redirect_stderr=true
|
|
|
|
|
stdout_logfile=/var/log/laravel_worker.log
|
2022-06-18 10:31:47 +02:00
|
|
|
EOF
|
2024-01-06 12:15:51 +01:00
|
|
|
info "Laravel supervisor config created"
|
2022-06-21 10:04:42 +02:00
|
|
|
else
|
2024-01-06 12:15:51 +01:00
|
|
|
info "artisan file not found"
|
2022-06-21 10:04:42 +02:00
|
|
|
fi
|
|
|
|
|
|
2022-09-05 15:08:24 +02:00
|
|
|
## Check if php.ini file exists
|
|
|
|
|
if [ -f /var/www/html/conf/php/php.ini ]; then
|
|
|
|
|
cp /var/www/html/conf/php/php.ini $PHP_INI_DIR/conf.d/
|
2024-01-06 12:15:51 +01:00
|
|
|
info "Custom php.ini file found and copied in $PHP_INI_DIR/conf.d/"
|
2022-09-05 15:08:24 +02:00
|
|
|
else
|
2024-01-06 12:15:51 +01:00
|
|
|
info "Custom php.ini file not found"
|
|
|
|
|
info "If you want to add a custom php.ini file, you add it in /var/www/html/conf/php/php.ini"
|
2022-09-05 15:08:24 +02:00
|
|
|
fi
|
2022-09-05 14:41:20 +02:00
|
|
|
|
2022-06-18 10:31:47 +02:00
|
|
|
supervisord -c /etc/supervisor/supervisord.conf
|