2018-02-23 02:33:40 +08:00
|
|
|
import json
|
2018-05-30 23:30:56 +08:00
|
|
|
import logging
|
2018-02-23 02:33:40 +08:00
|
|
|
import standard
|
|
|
|
import aws
|
|
|
|
|
2018-05-30 23:30:56 +08:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2018-02-23 02:33:40 +08:00
|
|
|
ENV_DICT = {
|
|
|
|
'standard': standard.StandardEnvironment,
|
|
|
|
'aws': aws.AwsEnvironment
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def load_env_from_file():
|
|
|
|
with open('server_config.json', 'r') as f:
|
|
|
|
config_content = f.read()
|
|
|
|
config_json = json.loads(config_content)
|
|
|
|
return config_json['server_config']
|
|
|
|
|
|
|
|
|
2018-02-26 00:23:52 +08:00
|
|
|
try:
|
|
|
|
__env_type = load_env_from_file()
|
|
|
|
env = ENV_DICT[__env_type]()
|
2018-06-01 00:27:26 +08:00
|
|
|
logger.info('Monkey\'s env is: {0}'.format(env.__class__.__name__))
|
2018-02-26 00:23:52 +08:00
|
|
|
except Exception:
|
2018-05-30 23:30:56 +08:00
|
|
|
logger.error('Failed initializing environment', exc_info=True)
|
2018-02-26 00:23:52 +08:00
|
|
|
raise
|