From e8706de11c1abb0ade24d0beba5a670c2f53b040 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 1 Feb 2021 08:30:50 +1100 Subject: [PATCH] Improve supervisor configuration --- config/cron.sh | 16 ---------------- config/shutdown.sh | 8 ++++++++ config/supervisor/supervisord.conf | 13 +++++++++---- docker-compose.yml | 22 +--------------------- 4 files changed, 18 insertions(+), 41 deletions(-) delete mode 100755 config/cron.sh create mode 100644 config/shutdown.sh diff --git a/config/cron.sh b/config/cron.sh deleted file mode 100755 index c951c66..0000000 --- a/config/cron.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -echo "Early Entry" - -cleanup () -{ - kill -s SIGTERM $! - exit 0 -} - -trap cleanup SIGINT SIGTERM - -while : -do - sleep 60 ; cd /var/www/app/ && php artisan schedule:run; -done diff --git a/config/shutdown.sh b/config/shutdown.sh new file mode 100644 index 0000000..3edbdf8 --- /dev/null +++ b/config/shutdown.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +printf "READY\n"; + +while read line; do + echo "Processing Event: $line" >&2; + kill -SIGQUIT $PPID +done < /dev/stdin \ No newline at end of file diff --git a/config/supervisor/supervisord.conf b/config/supervisor/supervisord.conf index ea7ccb0..355b802 100644 --- a/config/supervisor/supervisord.conf +++ b/config/supervisor/supervisord.conf @@ -1,5 +1,4 @@ [supervisord] -process_name=%(program_name)s_%(process_num)02d nodaemon=true user=invoiceninja pidfile=/var/run/supervisord/supervisord.pid @@ -8,7 +7,6 @@ logfile_maxbytes=0 loglevel=error [program:php-fpm] -process_name=%(program_name)s_%(process_num)02d autostart=true autorestart=true redirect_stderr=true @@ -19,7 +17,6 @@ stderr_logfile_maxbytes=0 command=php-fpm [program:scheduler] -process_name=%(program_name)s_%(process_num)02d autostart=true autorestart=true redirect_stderr=true @@ -39,4 +36,12 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 numprocs=2 -command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600 --daemon \ No newline at end of file +command=php artisan queue:work redis --sleep=3 --tries=3 --memory=256 + +[eventlistener:shutdown] +command=/shutdown.sh +events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bc1dbd6..3274bb0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,6 @@ services: # Vhost configuration #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro - # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated depends_on: @@ -29,8 +28,8 @@ services: env_file: env restart: always volumes: - # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - ./config/hosts:/etc/hosts:ro + - ./config/shutdown.sh:/usr/local/bin/shutdown.sh - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated depends_on: @@ -51,31 +50,12 @@ services: - MYSQL_PASSWORD=ninja - MYSQL_DATABASE=ninja volumes: - # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - ./docker/mysql/data:/var/lib/mysql:rw,delegated networks: - invoiceninja extra_hosts: - "in5.localhost:192.168.0.124 " #host and ip - # THIS IS ONLY A VALID CONFIGURATION FOR IN 5. DO NOT USE FOR IN 4. - # cron: - # image: invoiceninja/invoiceninja:5 - # env_file: env - # volumes: - # - ./config/cron.sh:/usr/local/bin/cron.sh - # - ./config/hosts:/etc/hosts:ro - # - ./docker/app/public:/var/www/app/public:rw,delegated - # - ./docker/app/storage:/var/www/app/storage:rw,delegated - # command: - # - cron.sh - # depends_on: - # - app - # networks: - # - invoiceninja - # extra_hosts: - # - "in5.localhost:192.168.0.124 " #host and ip - # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5. # cron: # image: invoiceninja/invoiceninja:alpine-4