Files
laravel-php-fpm/entrypoint.sh

67 lines
2.3 KiB
Bash
Raw Normal View History

2022-06-18 10:31:47 +02:00
#!/bin/sh
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
2022-06-18 10:31:47 +02:00
echo ""
echo "***********************************************************"
echo " Starting LARAVEL PHP-FPM Docker Container "
2022-06-18 10:31:47 +02:00
echo "***********************************************************"
set -e
## Check if the artisan file exists
2022-09-05 14:41:20 +02:00
if [ -f /var/www/html/artisan ]; then
2022-09-05 15:08:24 +02:00
echo "${Green} artisan file found, creating laravel supervisor config..."
##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"
autostart=true
autorestart=true
numprocs=1
2022-12-04 19:57:12 +02:00
user=www-data
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
autostart=true
autorestart=true
2022-06-21 20:01:57 +02:00
numprocs=$LARAVEL_PROCS_NUMBER
2022-12-04 19:57:12 +02:00
user=www-data
redirect_stderr=true
stdout_logfile=/var/log/laravel_worker.log
2022-06-18 10:31:47 +02:00
EOF
echo "${Green} Laravel supervisor config created"
else
echo "${Red} artisan file not found"
fi
2022-09-05 14:41:20 +02:00
## Check if the supervisor config file exists
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
echo "additional supervisor config found"
2022-07-05 05:40:09 +02:00
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
else
echo "${Red} Supervisor.conf not found"
2022-09-05 14:41:20 +02:00
echo "${Green} If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
echo "${Green} Start supervisor with default config..."
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/
echo "Custom php.ini file found and copied in $PHP_INI_DIR/conf.d/"
else
echo "Custom php.ini file not found"
echo "If you want to add a custom php.ini file, you add it in /var/www/html/conf/php/php.ini"
fi
2022-09-05 14:41:20 +02:00
2022-06-21 20:02:29 +02:00
echo ""
echo "**********************************"
echo " Starting Supervisord... "
echo "***********************************"
2022-06-18 10:31:47 +02:00
supervisord -c /etc/supervisor/supervisord.conf