containers/composer: forward SIGTERM to children

In docker compose and openshift SIGTERM is used to tell containers
to shut down gracefully. Forward the signal to the processes we spawned.
This commit is contained in:
Tom Gundersen 2022-03-16 01:24:35 +00:00 committed by Ondřej Budai
parent 367444635a
commit c21596cd99

View file

@ -10,6 +10,7 @@ import argparse
import contextlib
import os
import pathlib
import signal
import socket
import subprocess
import sys
@ -302,6 +303,13 @@ class Cli(contextlib.AbstractContextManager):
res = 0
sockets = self._prepare_sockets()
def handler(signum, frame):
proc_composer.terminate()
proc_worker.terminate()
proc_dnf_json.terminate()
signal.signal(signal.SIGTERM, handler)
liveness = pathlib.Path('/run/live')
liveness.touch()