mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 08:59:38 +01:00
Add custom supervisor conf
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
FROM php:7.2-fpm
|
||||
ENV WORKDIR=/var/www/html
|
||||
ENV STORAGE_DIR=/var/www/html/storage
|
||||
ENV LARAVEL_PROCS_NUMBER=2
|
||||
ENV STORAGE_DIR=${WORKDIR}/storage
|
||||
ENV LARAVEL_PROCS_NUMBER=1
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
|
||||
@@ -165,6 +165,10 @@ volumes:
|
||||
docker-compose up -d
|
||||
|
||||
```
|
||||
## Supervisord
|
||||
### Add more supervisor process in
|
||||
> /var/www/html/conf/worker/supervisor.conf
|
||||
|
||||
|
||||
> P.S. please give a star if you like it :wink:
|
||||
|
||||
|
||||
@@ -10,13 +10,9 @@ echo "***********************************************************"
|
||||
set -e
|
||||
|
||||
## Create PHP-FPM worker process
|
||||
TASK=/etc/supervisor/conf.d/worker.conf
|
||||
TASK=/etc/supervisor/conf.d/php-fpm.conf
|
||||
touch $TASK
|
||||
cat > "$TASK" <<EOF
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
|
||||
[program:php-fpm]
|
||||
command=/usr/local/sbin/php-fpm
|
||||
numprocs=1
|
||||
@@ -35,9 +31,6 @@ if [ -f $WORKDIR/artisan ]; then
|
||||
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"
|
||||
@@ -72,10 +65,16 @@ echo "Checking if storage directory exists"
|
||||
|
||||
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
|
||||
|
||||
## Check if the supervisor config file exists
|
||||
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
|
||||
echo "Custom 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..."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user