Parametrize and deliver (relevant) mkts config in `start_ahab()`
parent
277ca29018
commit
9ddfae44d2
|
@ -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.
|
CLI commons.
|
||||||
"""
|
|
||||||
|
'''
|
||||||
import os
|
import os
|
||||||
|
from pprint import pformat
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import trio
|
import trio
|
||||||
|
@ -59,12 +77,15 @@ def pikerd(loglevel, host, tl, pdb, tsdb):
|
||||||
|
|
||||||
from piker.data._ahab import start_ahab
|
from piker.data._ahab import start_ahab
|
||||||
log.info('Spawning `marketstore` supervisor')
|
log.info('Spawning `marketstore` supervisor')
|
||||||
ctn_ready = await n.start(
|
ctn_ready, config, (cid, pid) = await n.start(
|
||||||
start_ahab,
|
start_ahab,
|
||||||
'marketstored',
|
'marketstored',
|
||||||
)
|
)
|
||||||
await ctn_ready.wait()
|
log.info(
|
||||||
log.info('`marketstore` container:{uid} up')
|
f'`marketstored` up pid:{pid}\n'
|
||||||
|
f'container up cid:{cid} live with config:\n'
|
||||||
|
f'{pformat(config)}'
|
||||||
|
)
|
||||||
|
|
||||||
await trio.sleep_forever()
|
await trio.sleep_forever()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# piker: trading gear for hackers
|
# 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
|
# 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
|
# 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
|
import os
|
||||||
from typing import (
|
from typing import (
|
||||||
Optional,
|
Optional,
|
||||||
# Any,
|
Any,
|
||||||
)
|
)
|
||||||
from contextlib import asynccontextmanager as acm
|
from contextlib import asynccontextmanager as acm
|
||||||
|
|
||||||
|
@ -39,8 +39,13 @@ from .. import config
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
|
||||||
|
_config = {
|
||||||
|
'grpc_listen_port': 5995,
|
||||||
|
'ws_listen_port': 5993,
|
||||||
|
'log_level': 'debug',
|
||||||
|
}
|
||||||
|
|
||||||
_config = '''
|
_yaml_config = '''
|
||||||
# piker's ``marketstore`` config.
|
# piker's ``marketstore`` config.
|
||||||
|
|
||||||
# mount this config using:
|
# mount this config using:
|
||||||
|
@ -49,9 +54,9 @@ _config = '''
|
||||||
# 5993:5993 alpacamarkets/marketstore:latest
|
# 5993:5993 alpacamarkets/marketstore:latest
|
||||||
|
|
||||||
root_directory: data
|
root_directory: data
|
||||||
listen_port: 5993
|
listen_port: {ws_listen_port}
|
||||||
grpc_listen_port: 5995
|
grpc_listen_port: {grpc_listen_port}
|
||||||
log_level: debug
|
log_level: {log_level}
|
||||||
queryable: true
|
queryable: true
|
||||||
stop_grace_period: 0
|
stop_grace_period: 0
|
||||||
wal_rotate_interval: 5
|
wal_rotate_interval: 5
|
||||||
|
@ -76,7 +81,7 @@ triggers:
|
||||||
# config:
|
# config:
|
||||||
# filter: "nasdaq"
|
# filter: "nasdaq"
|
||||||
|
|
||||||
'''
|
'''.format(**_config)
|
||||||
|
|
||||||
|
|
||||||
class DockerNotStarted(Exception):
|
class DockerNotStarted(Exception):
|
||||||
|
@ -350,7 +355,12 @@ async def open_marketstored(
|
||||||
|
|
||||||
async def start_ahab(
|
async def start_ahab(
|
||||||
service_name: str,
|
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:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
|
@ -389,14 +399,18 @@ async def start_ahab(
|
||||||
)[2] # named user's uid
|
)[2] # named user's uid
|
||||||
)
|
)
|
||||||
|
|
||||||
task_status.started(cn_ready)
|
|
||||||
|
|
||||||
async with portal.open_context(
|
async with portal.open_context(
|
||||||
open_marketstored,
|
open_marketstored,
|
||||||
) as (ctx, first):
|
) as (ctx, first):
|
||||||
|
|
||||||
cid, pid = first
|
cid, pid = first
|
||||||
|
|
||||||
|
task_status.started((
|
||||||
|
cn_ready,
|
||||||
|
_config,
|
||||||
|
(cid, pid),
|
||||||
|
))
|
||||||
|
|
||||||
await trio.sleep_forever()
|
await trio.sleep_forever()
|
||||||
|
|
||||||
# since we demoted root perms in this parent
|
# since we demoted root perms in this parent
|
||||||
|
|
Loading…
Reference in New Issue