mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 17:09:39 +01:00
Refactoring
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
Red='\033[0;31m' # Red
|
||||
Green='\033[0;32m' # Green
|
||||
|
||||
echo ""
|
||||
echo "***********************************************************"
|
||||
echo " Starting LARAVEL PHP-FPM Docker Container "
|
||||
@@ -9,31 +8,19 @@ echo "***********************************************************"
|
||||
|
||||
set -e
|
||||
|
||||
## Create PHP-FPM worker process
|
||||
TASK=/etc/supervisor/conf.d/php-fpm.conf
|
||||
touch $TASK
|
||||
cat > "$TASK" <<EOF
|
||||
[program:php-fpm]
|
||||
command=/usr/local/sbin/php-fpm
|
||||
numprocs=1
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/php-fpm_consumer.err.log
|
||||
stdout_logfile=/var/log/php-fpm_consumer.out.log
|
||||
user=root
|
||||
priority=100
|
||||
EOF
|
||||
|
||||
## Check if the artisan file exists
|
||||
if [ -f $WORKDIR/artisan ]; then
|
||||
if [ -f /var/www/html/artisan ]; then
|
||||
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
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
[program:Laravel-scheduler]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=/bin/sh -c "while [ true ]; do (php $WORKDIR/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
||||
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
|
||||
@@ -43,7 +30,7 @@ if [ -f $WORKDIR/artisan ]; then
|
||||
|
||||
[program:Laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php $WORKDIR/artisan queue:work --sleep=3 --tries=3
|
||||
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=$LARAVEL_PROCS_NUMBER
|
||||
@@ -55,28 +42,19 @@ echo "${Green} Laravel supervisor config created"
|
||||
else
|
||||
echo "${Red} artisan file not found"
|
||||
fi
|
||||
#check if storage directory exists
|
||||
echo "Checking if storage directory exists"
|
||||
if [ -d "$STORAGE_DIR" ]; then
|
||||
echo "Directory $STORAGE_DIR exist. Fixing permissions..."
|
||||
chown -R www-data:www-data $STORAGE_DIR
|
||||
chmod -R 775 $STORAGE_DIR
|
||||
echo "${Green}Permissions fixed"
|
||||
|
||||
else
|
||||
echo "${Red} Directory $STORAGE_DIR does not exist"
|
||||
fi
|
||||
|
||||
## Check if the supervisor config file exists
|
||||
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
|
||||
echo "Custom supervisor config found"
|
||||
## Check if the supervisor config file exists
|
||||
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
|
||||
echo "additional supervisor config found"
|
||||
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
||||
else
|
||||
echo "${Red} Supervisor.conf not found"
|
||||
echo "If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
|
||||
echo "Start supervisor with default config..."
|
||||
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
|
||||
|
||||
|
||||
|
||||
echo ""
|
||||
echo "**********************************"
|
||||
echo " Starting Supervisord... "
|
||||
|
||||
Reference in New Issue
Block a user