mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 17:09:39 +01:00
Add checking if the project is based on Laravel
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#!/bin/sh
|
||||
Red='\033[0;31m' # Red
|
||||
Green='\033[0;32m' # Green
|
||||
|
||||
echo ""
|
||||
echo "***********************************************************"
|
||||
echo " Starting LARAVEL PHP-FPM Docker Container "
|
||||
echo " Starting LARAVEL PHP-FPM Docker Container "
|
||||
echo "***********************************************************"
|
||||
|
||||
set -e
|
||||
|
||||
## Create PHP-FPM worker process
|
||||
TASK=/etc/supervisor/conf.d/worker.conf
|
||||
touch $TASK
|
||||
cat > "$TASK" <<EOF
|
||||
@@ -22,28 +26,57 @@ stderr_logfile=/var/log/php-fpm_consumer.err.log
|
||||
stdout_logfile=/var/log/php-fpm_consumer.out.log
|
||||
user=root
|
||||
priority=100
|
||||
|
||||
[program:Laravel-scheduler]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=/bin/sh -c "while [ true ]; do (php /var/www/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=1
|
||||
user=root
|
||||
stdout_logfile=/var/log/laravel_scheduler.out.log
|
||||
redirect_stderr=true
|
||||
|
||||
[program:Laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan queue:work --sleep=3 --tries=3
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=2
|
||||
user=root
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/log/laravel_worker.log
|
||||
|
||||
EOF
|
||||
|
||||
## Check if the artisan file exists
|
||||
if [ -f $WORKDIR/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"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=1
|
||||
user=root
|
||||
stdout_logfile=/var/log/laravel_scheduler.out.log
|
||||
redirect_stderr=true
|
||||
|
||||
[program:Laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php $WORKDIR/artisan queue:work --sleep=3 --tries=3
|
||||
autostart=true
|
||||
autorestart=true
|
||||
numprocs=2
|
||||
user=root
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/log/laravel_worker.log
|
||||
EOF
|
||||
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"
|
||||
echo "Fixing permissions from $WORKDIR"
|
||||
chown -R www-data:www-data $WORKDIR/storage
|
||||
chmod -R 775 $WORKDIR/storage
|
||||
echo "${Green} Permissions fixed"
|
||||
fi
|
||||
|
||||
supervisord -c /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user