Add `--tsdb` flag to start `marketstore` with `pikerd`

mkts_backup
Tyler Goodlet 2022-02-17 14:29:41 -05:00
parent 8d09d63095
commit 86337430d8
1 changed files with 25 additions and 4 deletions

View File

@ -22,9 +22,16 @@ DEFAULT_BROKER = 'questrade'
@click.option('--tl', is_flag=True, help='Enable tractor logging') @click.option('--tl', is_flag=True, help='Enable tractor logging')
@click.option('--pdb', is_flag=True, help='Enable tractor debug mode') @click.option('--pdb', is_flag=True, help='Enable tractor debug mode')
@click.option('--host', '-h', default='127.0.0.1', help='Host address to bind') @click.option('--host', '-h', default='127.0.0.1', help='Host address to bind')
def pikerd(loglevel, host, tl, pdb): @click.option(
"""Spawn the piker broker-daemon. '--tsdb',
""" is_flag=True,
help='Enable local ``marketstore`` instance'
)
def pikerd(loglevel, host, tl, pdb, tsdb):
'''
Spawn the piker broker-daemon.
'''
from .._daemon import open_pikerd from .._daemon import open_pikerd
log = get_console_log(loglevel) log = get_console_log(loglevel)
@ -38,7 +45,21 @@ def pikerd(loglevel, host, tl, pdb):
)) ))
async def main(): async def main():
async with open_pikerd(loglevel=loglevel, debug_mode=pdb):
async with (
open_pikerd(
loglevel=loglevel,
debug_mode=pdb,
) as services,
trio.open_nursery() as n,
):
if tsdb:
from piker.data._ahab import start_ahab
log.info('Spawning `marketstore` supervisor')
ctn_ready = await n.start(start_ahab)
await ctn_ready.wait()
log.info('`marketstore` container:{uid} up')
await trio.sleep_forever() await trio.sleep_forever()
trio.run(main) trio.run(main)