Parametrize and deliver (relevant) mkts config in `start_ahab()`

l1_precision_fix
Tyler Goodlet 2022-05-10 13:32:56 -04:00
parent 277ca29018
commit 9ddfae44d2
2 changed files with 50 additions and 15 deletions

View File

@ -1,7 +1,25 @@
"""
# piker: trading gear for hackers
# Copyright (C) 2018-present Tyler Goodlet (in stewardship of pikers)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
CLI commons.
"""
'''
import os
from pprint import pformat
import click
import trio
@ -59,12 +77,15 @@ def pikerd(loglevel, host, tl, pdb, tsdb):
from piker.data._ahab import start_ahab
log.info('Spawning `marketstore` supervisor')
ctn_ready = await n.start(
ctn_ready, config, (cid, pid) = await n.start(
start_ahab,
'marketstored',
)
await ctn_ready.wait()
log.info('`marketstore` container:{uid} up')
log.info(
f'`marketstored` up pid:{pid}\n'
f'container up cid:{cid} live with config:\n'
f'{pformat(config)}'
)
await trio.sleep_forever()

View File

@ -1,5 +1,5 @@
# piker: trading gear for hackers
# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0)
# Copyright (C) 2018-present Tyler Goodlet (in stewardship of pikers)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -21,7 +21,7 @@ Supervisor for docker with included specific-image service helpers.
import os
from typing import (
Optional,
# Any,
Any,
)
from contextlib import asynccontextmanager as acm
@ -39,8 +39,13 @@ from .. import config
log = get_logger(__name__)
_config = {
'grpc_listen_port': 5995,
'ws_listen_port': 5993,
'log_level': 'debug',
}
_config = '''
_yaml_config = '''
# piker's ``marketstore`` config.
# mount this config using:
@ -49,9 +54,9 @@ _config = '''
# 5993:5993 alpacamarkets/marketstore:latest
root_directory: data
listen_port: 5993
grpc_listen_port: 5995
log_level: debug
listen_port: {ws_listen_port}
grpc_listen_port: {grpc_listen_port}
log_level: {log_level}
queryable: true
stop_grace_period: 0
wal_rotate_interval: 5
@ -76,7 +81,7 @@ triggers:
# config:
# filter: "nasdaq"
'''
'''.format(**_config)
class DockerNotStarted(Exception):
@ -350,7 +355,12 @@ async def open_marketstored(
async def start_ahab(
service_name: str,
task_status: TaskStatus[trio.Event] = trio.TASK_STATUS_IGNORED,
task_status: TaskStatus[
tuple[
trio.Event,
dict[str, Any],
],
] = trio.TASK_STATUS_IGNORED,
) -> None:
'''
@ -389,14 +399,18 @@ async def start_ahab(
)[2] # named user's uid
)
task_status.started(cn_ready)
async with portal.open_context(
open_marketstored,
) as (ctx, first):
cid, pid = first
task_status.started((
cn_ready,
_config,
(cid, pid),
))
await trio.sleep_forever()
# since we demoted root perms in this parent