Skip to content

Commit

Permalink
Make supervisord exit when key processes die, fixes #1137 (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Oct 9, 2018
1 parent d91e190 commit 58f8023
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 0 additions & 1 deletion containers/ddev-webserver/files/etc/supervisor/apache.conf
@@ -1,5 +1,4 @@
[program:apache2]
; startsecs = 1
stopwaitsecs = 20
startretries=10
stopsignal = WINCH
Expand Down
Expand Up @@ -3,3 +3,8 @@ logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=//var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)

[eventlistener:child_exit_monitor]
command=/usr/local/bin/kill_supervisor.py
process_name=child_exit_monitor
events=PROCESS_STATE_FATAL,PROCESS_STATE_EXITED
28 changes: 28 additions & 0 deletions containers/ddev-webserver/files/usr/local/bin/kill_supervisor.py
@@ -0,0 +1,28 @@
#!/usr/bin/env python
import sys
import os
import signal

# From https://blog.zhaw.ch/icclab/process-management-in-docker-containers/

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()
write_stdout('This line kills supervisor: ' + line);
try:
pidfile = open('/var/run/supervisord.pid','r')
pid = int(pidfile.readline());
os.kill(pid, signal.SIGQUIT)
except Exception as e:
write_stdout('Could not kill supervisor: ' + e.strerror + '\n')
write_stdout('RESULT 2\nOK')
if __name__ == '__main__':
main()
import sys
2 changes: 1 addition & 1 deletion pkg/version/version.go
Expand Up @@ -25,7 +25,7 @@ var DockerComposeFileFormatVersion = "3.6"
var WebImg = "drud/ddev-webserver"

// WebTag defines the default web image tag for drud dev
var WebTag = "20181004_check_cms_content" // Note that this can be overridden by make
var WebTag = "20180929_nginx_quit_immediately" // Note that this can be overridden by make

// DBImg defines the default db image used for applications.
var DBImg = "drud/ddev-dbserver"
Expand Down

0 comments on commit 58f8023

Please sign in to comment.