WIP implement tasker daemon on new settings setup
This commit is contained in:
parent
b19b948be3
commit
3d39fea7f8
@ -4,13 +4,3 @@ runtime_dir =
|
|||||||
id =
|
id =
|
||||||
data_dir =
|
data_dir =
|
||||||
dispatch_delay = 0.01
|
dispatch_delay = 0.01
|
||||||
|
|
||||||
[database]
|
|
||||||
engine =
|
|
||||||
name = chaind
|
|
||||||
driver =
|
|
||||||
user =
|
|
||||||
password =
|
|
||||||
host =
|
|
||||||
port =
|
|
||||||
debug = 0
|
|
||||||
|
@ -3,6 +3,8 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
|
import chainlib.cli
|
||||||
|
import chainsyncer.cli
|
||||||
import chaind.cli
|
import chaind.cli
|
||||||
from chaind.setup import Environment
|
from chaind.setup import Environment
|
||||||
from chaind.filter import StateFilter
|
from chaind.filter import StateFilter
|
||||||
@ -24,21 +26,32 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
|||||||
|
|
||||||
env = Environment(domain='eth', env=os.environ)
|
env = Environment(domain='eth', env=os.environ)
|
||||||
|
|
||||||
arg_flags = chaind.cli.argflag_local_sync
|
arg_flags = chainlib.cli.argflag_std_base | chainlib.cli.Flag.CHAIN_SPEC
|
||||||
argparser = chaind.cli.ArgumentParser(arg_flags)
|
argparser = chainlib.cli.ArgumentParser(arg_flags)
|
||||||
local_arg_flags = chaind.cli.argflag_local_sync
|
|
||||||
argparser.process_local_flags(local_arg_flags)
|
|
||||||
args = argparser.parse_args()
|
|
||||||
config = chaind.cli.Config.from_args('eth', args, arg_flags, local_arg_flags)
|
|
||||||
|
|
||||||
|
local_arg_flags = chaind.cli.argflag_local_base
|
||||||
|
chaind.cli.process_flags(argparser, local_arg_flags)
|
||||||
|
|
||||||
|
sync_flags = chainsyncer.cli.SyncFlag.RANGE | chainsyncer.cli.SyncFlag.HEAD
|
||||||
|
chainsyncer.cli.process_flags(argparser, sync_flags)
|
||||||
|
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
|
base_config_dir = [
|
||||||
|
chainsyncer.cli.config_dir,
|
||||||
|
chaind.cli.config_dir,
|
||||||
|
]
|
||||||
|
config = chainlib.cli.Config.from_args(args, arg_flags, base_config_dir=base_config_dir)
|
||||||
|
config = chainsyncer.cli.process_config(config, args, sync_flags)
|
||||||
|
config = chaind.cli.process_config(config, args, local_arg_flags)
|
||||||
|
config.add('eth', 'CHAIND_ENGINE', False)
|
||||||
logg.debug('config loaded:\n{}'.format(config))
|
logg.debug('config loaded:\n{}'.format(config))
|
||||||
|
|
||||||
settings = ChaindEthSettings()
|
settings = ChaindEthSettings(include_sync=True)
|
||||||
settings.process(config)
|
settings.process(config)
|
||||||
|
|
||||||
logg.debug('settings:\n{}'.format(settings))
|
logg.debug('settings:\n{}'.format(settings))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
queue_adapter = ChaindFsAdapter(
|
queue_adapter = ChaindFsAdapter(
|
||||||
settings.get('CHAIN_SPEC'),
|
settings.get('CHAIN_SPEC'),
|
||||||
|
@ -5,6 +5,7 @@ import signal
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import chainlib.eth.cli
|
import chainlib.eth.cli
|
||||||
|
import chaind.cli
|
||||||
from chaind.session import SessionController
|
from chaind.session import SessionController
|
||||||
from chaind.setup import Environment
|
from chaind.setup import Environment
|
||||||
from chaind.error import (
|
from chaind.error import (
|
||||||
@ -30,6 +31,7 @@ from chaind.adapters.fs import ChaindFsAdapter
|
|||||||
# local imports
|
# local imports
|
||||||
from chaind.eth.dispatch import EthDispatcher
|
from chaind.eth.dispatch import EthDispatcher
|
||||||
from chaind.eth.cache import EthCacheTx
|
from chaind.eth.cache import EthCacheTx
|
||||||
|
from chaind.eth.settings import ChaindEthSettings
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -41,32 +43,29 @@ env = Environment(domain='eth', env=os.environ)
|
|||||||
|
|
||||||
arg_flags = chainlib.eth.cli.argflag_std_read
|
arg_flags = chainlib.eth.cli.argflag_std_read
|
||||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||||
argparser.add_argument('--data-dir', type=str, help='data directory')
|
|
||||||
argparser.add_argument('--runtime-dir', type=str, help='runtime directory')
|
|
||||||
argparser.add_argument('--session-id', dest='session_id', type=str, help='session identifier')
|
|
||||||
argparser.add_argument('--dispatch-delay', dest='dispatch_delay', type=float, help='socket timeout before processing queue')
|
|
||||||
args = argparser.parse_args()
|
|
||||||
extra_args = {
|
|
||||||
'runtime_dir': 'SESSION_RUNTIME_DIR',
|
|
||||||
'data_dir': 'SESSION_DATA_DIR',
|
|
||||||
'session_id': 'SESSION_ID',
|
|
||||||
'dispatch_delay': 'SESSION_DISPATCH_DELAY',
|
|
||||||
}
|
|
||||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, base_config_dir=config_dir)
|
|
||||||
|
|
||||||
logg.debug('session id {} {}'.format(type(config.get('SESSION_ID')), config.get('SESSION_ID')))
|
local_arg_flags = chaind.cli.argflag_local_base | chaind.cli.ChaindFlag.DISPATCH | chaind.cli.ChaindFlag.SOCKET
|
||||||
if config.get('SESSION_ID') == None:
|
chaind.cli.process_flags(argparser, local_arg_flags)
|
||||||
config.add(env.session, 'SESSION_ID', exists_ok=True)
|
|
||||||
if config.get('SESSION_RUNTIME_DIR') == None:
|
args = argparser.parse_args()
|
||||||
config.add(env.runtime_dir, 'SESSION_RUNTIME_DIR', exists_ok=True)
|
|
||||||
if config.get('SESSION_DATA_DIR') == None:
|
base_config_dir = [chaind.cli.config_dir]
|
||||||
config.add(env.data_dir, 'SESSION_DATA_DIR', exists_ok=True)
|
config = chainlib.cli.Config.from_args(args, arg_flags, base_config_dir=base_config_dir)
|
||||||
if not config.get('SESSION_SOCKET_PATH'):
|
config = chaind.cli.process_config(config, args, local_arg_flags)
|
||||||
socket_path = os.path.join(config.get('SESSION_RUNTIME_DIR'), config.get('SESSION_ID'), 'chaind.sock')
|
config.add('eth', 'CHAIND_ENGINE', False)
|
||||||
config.add(socket_path, 'SESSION_SOCKET_PATH', True)
|
|
||||||
|
|
||||||
logg.debug('config loaded:\n{}'.format(config))
|
logg.debug('config loaded:\n{}'.format(config))
|
||||||
|
|
||||||
|
settings = ChaindEthSettings()
|
||||||
|
settings.process(config)
|
||||||
|
|
||||||
|
logg.debug('settings:\n{}'.format(settings))
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_outgoing(chain_spec, adapter, rpc, limit=100):
|
def process_outgoing(chain_spec, adapter, rpc, limit=100):
|
||||||
upcoming = adapter.upcoming()
|
upcoming = adapter.upcoming()
|
||||||
logg.info('process {} {} {}'.format(chain_spec, adapter, rpc))
|
logg.info('process {} {} {}'.format(chain_spec, adapter, rpc))
|
||||||
|
Loading…
Reference in New Issue
Block a user