You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

8 years ago
#!/usr/bin/env python3
#
# Copyright (c) 2016-2018, Neil Booth
#
# All rights reserved.
#
# See the file "LICENCE" for information about the copyright
8 years ago
# and warranty status of this software.
'''Script to kick off the server.'''
8 years ago
import logging
import sys
8 years ago
import traceback
from electrumx import Controller, Env
from electrumx.lib.util import CompactFormatter, make_logger
8 years ago
def main():
'''Set up logging and run the server.'''
log_fmt = Env.default('LOG_FORMAT', '%(levelname)s:%(name)s:%(message)s')
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(CompactFormatter(log_fmt))
logger = make_logger('electrumx', handler=handler, level='INFO')
logger.info('ElectrumX server starting')
8 years ago
try:
env = Env()
logger.info(f'logging level: {env.log_level}')
logger.setLevel(env.log_level)
controller = Controller(env)
controller.run()
8 years ago
except Exception:
traceback.print_exc()
logger.critical('ElectrumX server terminated abnormally')
8 years ago
else:
logger.info('ElectrumX server terminated normally')
8 years ago
if __name__ == '__main__':
main()