-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
59 lines (44 loc) · 1.46 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# coding=utf-8
"""
Main Module, creates eventloop parses config and so on...
"""
import argparse
import asyncio
from multiprocessing.context import Process
import sys
import config
import database
import database_logging
__author__ = 'konsti'
import logging
logger = logging.getLogger(__name__)
def run(configfile):
"""
This method is called after initializing the framework and starts the configured servers.
@param configfile: Path referring to the xml configfile.
"""
logger.debug('run() method started!')
for role in config.get_roles(configfile):
process = Process(target=role)
print('Starting Process!')
process.start()
logger.debug('run() is done!')
def main(args=sys.argv[1:]):
"""
main :)
@param args: the args used for the parser, just useful for testing
"""
parser = argparse.ArgumentParser(description='Tool MainExecutable')
parser.add_argument('-d', '--database', type=str, metavar='"Connection String"', required=True)
parser.add_argument('-c', '--config', type=str, metavar='"Config Path"', default='configfile.xml')
parser.add_argument('--debug', action='store_true')
args = parser.parse_args(args)
database.DATABASE_STRING = args.database
database_logging.start_logging_process()
database_logging.configure_logger()
loop = asyncio.get_event_loop()
loop.call_soon(run, args.config)
loop.run_forever()
return 0
if __name__ == '__main__':
exit(main())