fix: handle SIGTERM too
This commit is contained in:
parent
5586d1fc9c
commit
bd97b891f4
1 changed files with 5 additions and 1 deletions
|
@ -2,7 +2,7 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from signal import signal, SIGINT, SIGTERM, SIGABRT
|
from signal import signal, SIGINT, SIGTERM
|
||||||
|
|
||||||
class Runnable:
|
class Runnable:
|
||||||
_is_running : bool
|
_is_running : bool
|
||||||
|
@ -32,6 +32,10 @@ class Runnable:
|
||||||
else:
|
else:
|
||||||
logging.info("Received SIGINT, stopping gracefully...")
|
logging.info("Received SIGINT, stopping gracefully...")
|
||||||
self._stop_task = asyncio.get_event_loop().create_task(self.stop(force=self._stop_task is not None))
|
self._stop_task = asyncio.get_event_loop().create_task(self.stop(force=self._stop_task is not None))
|
||||||
|
if signum == SIGTERM:
|
||||||
|
logging.info("Received SIGTERM, terminating")
|
||||||
|
self._stop_task = asyncio.get_event_loop().create_task(self.stop(force=True))
|
||||||
|
|
||||||
|
|
||||||
signal(SIGINT, signal_handler)
|
signal(SIGINT, signal_handler)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue