Activate docker daemons via flags using exit stack

master
Tyler Goodlet 2023-05-23 12:12:09 -04:00
parent e7a172b656
commit d094625bd6
1 changed files with 25 additions and 5 deletions

View File

@ -19,6 +19,7 @@ CLI commons.
''' '''
import os import os
from contextlib import AsyncExitStack
import click import click
import trio import trio
@ -69,8 +70,8 @@ def pikerd(
Spawn the piker broker-daemon. Spawn the piker broker-daemon.
''' '''
from .. import service
from ..service import open_pikerd
log = get_console_log(loglevel) log = get_console_log(loglevel)
if pdb: if pdb:
@ -90,17 +91,36 @@ def pikerd(
) )
async def main(): async def main():
service_mngr: service.Services
async with ( async with (
open_pikerd( service.open_pikerd(
tsdb=tsdb,
es=es,
loglevel=loglevel, loglevel=loglevel,
debug_mode=pdb, debug_mode=pdb,
registry_addr=reg_addr, registry_addr=reg_addr,
), # normally delivers a ``Services`` handle ) as service_mngr, # normally delivers a ``Services`` handle
trio.open_nursery() as n, trio.open_nursery() as n,
AsyncExitStack() as stack,
): ):
if tsdb:
dname, conf = await stack.enter_async_context(
service.marketstore.start_ahab_daemon(
service_mngr,
loglevel=loglevel,
)
)
log.info(f'TSDB `{dname}` up with conf:\n{conf}')
if es:
dname, conf = await stack.enter_async_context(
service.elastic.start_ahab_daemon(
service_mngr,
loglevel=loglevel,
)
)
log.info(f'DB `{dname}` up with conf:\n{conf}')
await trio.sleep_forever() await trio.sleep_forever()