Skip to content
Snippets Groups Projects
Verified Commit 5b18b90c authored by David Beniamine's avatar David Beniamine
Browse files

Stop properly sympa container on program failure

parent df42f887
Branches
No related tags found
No related merge requests found
...@@ -49,4 +49,8 @@ ENV LANGUAGE en_US:en ...@@ -49,4 +49,8 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8 ENV LC_ALL en_US.UTF-8
COPY exit-event-listener.py /usr/local/bin
RUN chmod +x /usr/local/bin/exit-event-listener.py
ENTRYPOINT /entrypoint ENTRYPOINT /entrypoint
#!/usr/bin/env python3
# From https://stackoverflow.com/a/37527488
import os
import signal
from supervisor import childutils
def main():
while True:
headers, payload = childutils.listener.wait()
childutils.listener.ok()
if headers['eventname'] != 'PROCESS_STATE_FATAL':
continue
os.kill(os.getppid(), signal.SIGTERM)
if __name__ == "__main__":
main()
...@@ -126,3 +126,7 @@ stdout_logfile_maxbytes=0 ...@@ -126,3 +126,7 @@ stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr stderr_logfile=/dev/stderr
[eventlistener:exit_on_any_fatal]
events=PROCESS_STATE_FATAL
command=exit-event-listener.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment