lbry-sdk/lbry/wallet/server/cli.py

47 lines
1.4 KiB
Python
Raw Normal View History

2018-12-12 12:54:38 -05:00
import logging
import traceback
import argparse
from lbry.wallet.server.env import Env
2022-01-06 12:47:12 -05:00
from lbry.wallet.server.block_processor import BlockProcessor
from lbry.wallet.server.chain_reader import BlockchainReaderServer
2018-12-12 12:54:38 -05:00
def get_argument_parser():
parser = argparse.ArgumentParser(
2021-03-24 17:07:17 -03:00
prog="lbry-hub"
2018-12-12 12:54:38 -05:00
)
Env.contribute_to_arg_parser(parser)
return parser
2018-12-12 12:54:38 -05:00
def main():
parser = get_argument_parser()
args = parser.parse_args()
2021-04-28 16:46:24 -04:00
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-4s %(name)s:%(lineno)d: %(message)s")
logging.info('lbry.server starting')
logging.getLogger('aiohttp').setLevel(logging.WARNING)
logging.getLogger('elasticsearch').setLevel(logging.WARNING)
2022-01-06 12:47:12 -05:00
if args.es_mode == 'writer':
try:
block_processor = BlockProcessor(Env.from_arg_parser(args))
block_processor.run()
except Exception:
traceback.print_exc()
logging.critical('block processor terminated abnormally')
else:
logging.info('block processor terminated normally')
2018-12-12 12:54:38 -05:00
else:
2022-01-06 12:47:12 -05:00
try:
server = BlockchainReaderServer(Env.from_arg_parser(args))
server.run()
except Exception:
traceback.print_exc()
logging.critical('server terminated abnormally')
else:
logging.info('server terminated normally')
2018-12-12 12:54:38 -05:00
if __name__ == "__main__":
main()