hub/scribe/blockchain/__main__.py

31 lines
793 B
Python
Raw Normal View History

2022-04-04 16:34:51 +02:00
import os
import logging
import traceback
import argparse
from scribe.common import setup_logging
2022-05-05 20:07:39 +02:00
from scribe.blockchain.env import BlockchainEnv
from scribe.blockchain.service import BlockchainProcessorService
def main():
parser = argparse.ArgumentParser(
prog='scribe'
)
2022-05-05 20:07:39 +02:00
BlockchainEnv.contribute_to_arg_parser(parser)
args = parser.parse_args()
2022-04-04 16:34:51 +02:00
try:
2022-05-05 20:07:39 +02:00
env = BlockchainEnv.from_arg_parser(args)
2022-04-04 16:34:51 +02:00
setup_logging(os.path.join(env.db_dir, 'scribe.log'))
block_processor = BlockchainProcessorService(env)
block_processor.run()
except Exception:
traceback.print_exc()
logging.critical('scribe terminated abnormally')
else:
logging.info('scribe terminated normally')
if __name__ == "__main__":
main()