Support online railway deployment

This commit is contained in:
Pin Fang
2023-03-25 10:02:19 +08:00
parent 04fec4a585
commit 2d0935741c
6 changed files with 34 additions and 11 deletions

View File

@@ -10,11 +10,18 @@ def load_config():
global config
config_path = "./config.json"
if not os.path.exists(config_path):
raise Exception('配置文件不存在,请根据config-template.json模板创建config.json文件')
logger.info('配置文件不存在,将使用config-template.json模板')
config_path = "./config-template.json"
config_str = read_file(config_path)
# 将json字符串反序列化为dict类型
config = json.loads(config_str)
# override config with environment variables.
# Some online deployment platforms (e.g. Railway) deploy project from github directly. So you shouldn't put your secrets like api key in a config file, instead use environment variables to override the default config.
for name, value in os.environ.items():
config[name] = value
logger.info("[INIT] load config: {}".format(config))