From 3afb801912ea620fcdb669c92f1a41f1f7987728 Mon Sep 17 00:00:00 2001 From: Mathieu Bruyen Date: Sat, 15 Dec 2018 11:26:20 +0100 Subject: [PATCH] close supervisord on fatal + full binary paths --- Dockerfile | 1 + manage-supervisord.py | 23 +++++++++++++++++++++++ supervisor.conf | 10 +++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 manage-supervisord.py diff --git a/Dockerfile b/Dockerfile index 0515ce9..0ae4a76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf COPY php-fpm.conf /etc/php7/php-fpm.d/ttrss.conf COPY install-db.php /var/lib/tt-rss-install/install-db.php COPY supervisor.conf /var/lib/tt-rss-install/supervisor.conf +COPY manage-supervisord.py /var/lib/tt-rss-install/manage-supervisord.py ADD https://git.tt-rss.org/fox/tt-rss/archive/18.12.tar.gz /tmp/ttrss.tar.gz RUN tar -xzf /tmp/ttrss.tar.gz -C /var/lib diff --git a/manage-supervisord.py b/manage-supervisord.py new file mode 100644 index 0000000..1cc953b --- /dev/null +++ b/manage-supervisord.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +import sys +import os +import signal + +def write_stdout(s): + sys.stdout.write(s) + sys.stdout.flush() + +def write_stderr(s): + sys.stderr.write(s) + sys.stderr.flush() + +def main(): + while 1: + write_stdout('READY\n') + line = sys.stdin.readline() + os.kill(1, signal.SIGTERM) + write_stdout('RESULT 2\nOK') + +if __name__ == '__main__': + main() + import sys \ No newline at end of file diff --git a/supervisor.conf b/supervisor.conf index 5e82d72..ff717eb 100644 --- a/supervisor.conf +++ b/supervisor.conf @@ -4,7 +4,7 @@ user=nginx logfile=/tmp/supervisord.log [program:nginx] -command=nginx -g "daemon off;" +command=/usr/sbin/nginx -g "daemon off;" autostart=true autorestart=true stdout_logfile=/dev/stdout @@ -13,7 +13,7 @@ stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 [program:php-fpm] -command=php-fpm7 -F +command=/usr/sbin/php-fpm7 -F autostart=true autorestart=true stdout_logfile=/dev/stdout @@ -22,7 +22,7 @@ stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 [eventlistener:feed-update] -command=php7 -r 'while (true) { print("READY\n"); readline(); passthru("php7 /var/lib/tt-rss/update.php --daemon-loop"); print("RESULT 2\nOK\n"); }' +command=/usr/bin/php7 -r 'while (true) { print("READY\n"); readline(); passthru("/usr/bin/php7 /var/lib/tt-rss/update.php --daemon-loop"); print("RESULT 2\nOK\n"); }' events=TICK_60 autostart=true autorestart=true @@ -30,3 +30,7 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 + +[eventlistener:quit_on_failure] +events=PROCESS_STATE_FATAL +command=/usr/bin/python /var/lib/tt-rss-install/manage-supervisord.py