3
0

support systemd notify and watchdog

This commit is contained in:
2022-04-12 11:46:30 +02:00
parent 416b0c1770
commit 5cecfb4bbe
3 changed files with 94 additions and 8 deletions
+12 -7
View File
@@ -12,6 +12,8 @@ import capport.utils.cli
import capport.utils.nft_set
import trio
from capport import cptypes
from capport.utils.sd_notify import open_sdnotify
_logger = logging.getLogger(__name__)
@@ -42,13 +44,16 @@ class ControlApp(capport.comm.hub.HubApplication):
async def amain(config: capport.config.Config) -> None:
app = ControlApp()
hub = capport.comm.hub.Hub(config=config, app=app, is_controller=True)
app.hub = hub
async with trio.open_nursery() as nursery:
# hub.run loads the statefile from disk before signalling it was "started"
await nursery.start(hub.run)
app.apply_db_entries(hub.database.entries())
async with open_sdnotify() as sn:
app = ControlApp()
hub = capport.comm.hub.Hub(config=config, app=app, is_controller=True)
app.hub = hub
async with trio.open_nursery() as nursery:
# hub.run loads the statefile from disk before signalling it was "started"
await nursery.start(hub.run)
await sn.send('READY=1', 'STATUS=Deploying initial entries to nftables set')
app.apply_db_entries(hub.database.entries())
await sn.send('STATUS=Kernel fully synchronized')
def main() -> None: