Handle SIGINT and SIGTERM (more) gracefully
This commit is contained in:
parent
1b244b0c21
commit
3348c53aea
2 changed files with 28 additions and 7 deletions
9
node.py
9
node.py
|
@ -3,10 +3,12 @@
|
|||
# Copyright (c) 2025 Julian Müller (ChaoticByte)
|
||||
|
||||
import asyncio
|
||||
import signal
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
from argh.log import log
|
||||
from argh.node import node_from_yml
|
||||
|
||||
|
||||
|
@ -18,4 +20,11 @@ if __name__ == "__main__":
|
|||
|
||||
node = node_from_yml(args.config.read_text())
|
||||
|
||||
def _sigint(*args):
|
||||
# don't need special sigint behaviour
|
||||
# -> send SIGTERM
|
||||
signal.raise_signal(signal.SIGTERM)
|
||||
signal.signal(signal.SIGINT, _sigint)
|
||||
|
||||
asyncio.run(node.run())
|
||||
log("Bye")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue