Skip to content

Instantly share code, notes, and snippets.

@wuriyanto48
Last active December 22, 2025 05:17
Show Gist options
  • Select an option

  • Save wuriyanto48/4bd62113a16f985071441f60e7c302cd to your computer and use it in GitHub Desktop.

Select an option

Save wuriyanto48/4bd62113a16f985071441f60e7c302cd to your computer and use it in GitHub Desktop.
Run Process With Supervisord (queue, scheduler, nginx, php-fpm), Example with PHP Laravel and Nginx

View Supervisord Processes

supervisorctl -c /etc/supervisor/supervisord.conf status

View Scheduler processes

php /var/www/html/artisan schedule:list

View Queue processes

Show Realtime Logs

tail -f /var/www/html/storage/logs/worker.log
tail -f /var/www/html/storage/logs/php-fpm.out.log
tail -f /var/www/html/storage/logs/nginx.out.log
tail -f /var/www/html/storage/logs/scheduler.log
FROM php:8.2-fpm
# Set working directory
WORKDIR /var/www/html
USER root
# Set timezone to Asia/Jakarta
RUN apk update
RUN ln -snf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && echo Asia/Jakarta > /etc/timezone
# Copy application files
COPY ./.docker/php.ini /etc/php7/php.ini
RUN sed -i 's|root /var/www/html|root /var/www/html/public|' /etc/nginx/conf.d/default.conf
COPY /.docker/nginx.conf /etc/nginx/nginx.conf
COPY /.docker/www.conf /etc/php7/php-fpm.d/www.conf
COPY /.docker/default.conf /etc/nginx/default.conf
COPY /.docker/supervisord.conf /etc/supervisor/supervisord.conf
COPY . .
RUN mkdir -p /var/www/html/bootstrap \
/var/www/html/bootstrap/cache \
/var/www/html/storage/debugbar \
/var/www/html/storage/app \
/var/www/html/storage/app/public \
/var/www/html/storage/framework \
/var/www/html/storage/framework/views \
/var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/cache \
/var/www/html/storage/framework/cache/data \
/var/www/html/storage/framework/testing \
/var/www/html/storage/logs \
/var/www/html/public/temp
RUN chmod 777 /var/www/html/bootstrap \
/var/www/html/bootstrap/cache \
/var/www/html/storage/debugbar \
/var/www/html/storage/app \
/var/www/html/storage/app/public \
/var/www/html/storage/framework \
/var/www/html/storage/framework/views \
/var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/cache \
/var/www/html/storage/framework/cache/data \
/var/www/html/storage/framework/testing \
/var/www/html/storage/logs \
/var/www/html/storage/logs/ \
/var/www/html/public/temp
RUN touch /var/www/html/storage/logs/laravel.log && chmod 666 /var/www/html/storage/logs/laravel.log
RUN composer install
EXPOSE 80
USER user
# Start Supervisor
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
[supervisord]
logfile=/var/www/html/storage/logs/supervisord.log
pidfile=/tmp/supervisord.pid
childlogdir=/var/www/html/storage/logs/
[unix_http_server]
file=/tmp/supervisor.sock
chmod=0700
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
[program:php-fpm]
command=php-fpm7 -F -R
stdout_logfile=/var/www/html/storage/logs/php-fpm.out.log
stdout_logfile_maxbytes=0
stderr_logfile=/var/www/html/storage/logs/php-fpm.err.log
stderr_logfile_maxbytes=0
autorestart=true
startretries=3
[program:nginx]
command=nginx -g 'daemon off;'
stdout_logfile=/var/www/html/storage/logs/nginx.out.log
stdout_logfile_maxbytes=0
stderr_logfile=/var/www/html/storage/logs/nginx.err.log
stderr_logfile_maxbytes=0
autorestart=true
startretries=3
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --timeout=90
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/worker.log
stopasgroup=true
killasgroup=true
[program:laravel-scheduler]
command=php /var/www/html/artisan schedule:work
autostart=true
autorestart=true
stdout_logfile=/var/www/html/storage/logs/scheduler.log
redirect_stderr=true
stopasgroup=true
killasgroup=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment