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.

50 lines
1.1 KiB

8 years ago
#!/usr/bin/env python3
8 years ago
# See the file "LICENSE" for information about the copyright
8 years ago
# and warranty status of this software.
import asyncio
import logging
import os
import traceback
from server.env import Env
from server.server import Server
def main_loop():
'''Get tasks; loop until complete.'''
if os.geteuid() == 0:
raise Exception('DO NOT RUN AS ROOT! Create an unpriveleged user '
'account and use that')
env = Env()
logging.info('switching current directory to {}'.format(env.db_dir))
os.chdir(env.db_dir)
server = Server(env)
tasks = server.async_tasks()
8 years ago
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(asyncio.gather(*tasks))
finally:
loop.close()
def main():
'''Set up logging, enter main loop.'''
logging.basicConfig(level=logging.INFO)
logging.info('ElectrumX server starting')
try:
main_loop()
except Exception:
traceback.print_exc()
logging.critical('ElectrumX server terminated abnormally')
else:
logging.info('ElectrumX server terminated normally')
if __name__ == '__main__':
main()