diff --git a/cli/utils/sig.py b/cli/utils/sig.py index 00524102..e23ef53f 100644 --- a/cli/utils/sig.py +++ b/cli/utils/sig.py @@ -1,3 +1,4 @@ +import os import signal import asyncio import logging @@ -33,6 +34,10 @@ async def _signal_handling( async def _handle_termination_signal( logger: naz.log.BaseLogger, _signal: "signal.Signals", client: naz.Client ) -> None: + """ + Handle termination signal by cleanly shutting down the `naz` client. + At the end of it, send a `SIGKILL` signal to `naz` to make sure it exists. + """ logger.log( logging.INFO, { @@ -49,4 +54,6 @@ async def _handle_termination_signal( logging.INFO, {"event": "naz.cli.signals", "stage": "end", "state": "client has succesfully shutdown"}, ) + + os.kill(client._PID, signal.SIGKILL) return