refactor: Separate loading config from file and environment variables
This commit is contained in:
parent
7bc8496b6f
commit
b4a59f7c7c
@ -2,7 +2,8 @@ import os
|
||||
import sys
|
||||
|
||||
import ankisyncd
|
||||
import ankisyncd.config
|
||||
from ankisyncd.config import load_from_file
|
||||
from ankisyncd.config import load_from_env
|
||||
from ankisyncd import logging
|
||||
from ankisyncd.sync_app import SyncApp
|
||||
from ankisyncd.server import run_server
|
||||
@ -19,7 +20,8 @@ def main():
|
||||
"ankisyncd {} ({})".format(ankisyncd._get_version(), ankisyncd._homepage)
|
||||
)
|
||||
|
||||
config = ankisyncd.config.load(sys.argv)
|
||||
config = load_from_file(sys.argv)
|
||||
load_from_env(config)
|
||||
|
||||
ankiserver = SyncApp(config)
|
||||
run_server(ankiserver, config["host"], int(config["port"]))
|
||||
|
||||
@ -26,7 +26,7 @@ def load_from_env(conf):
|
||||
logger.info("Setting {} from ENV".format(config_key))
|
||||
|
||||
|
||||
def load(path=None):
|
||||
def load_from_file(path=None):
|
||||
# backwards compat
|
||||
if len(path) > 1:
|
||||
path = path[1]
|
||||
@ -42,7 +42,6 @@ def load(path=None):
|
||||
parser.read(path)
|
||||
conf = parser["sync_app"]
|
||||
logger.info("Loaded config from {}".format(path))
|
||||
load_from_env(conf)
|
||||
return conf
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
Loading…
Reference in New Issue
Block a user