diff --git a/Dockerfile b/Dockerfile index 2c6d548..23d4cf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,3 @@ COPY ./ ./ RUN chmod 777 /app/configs/sources.json -RUN python update.py --config - -RUN python update.py --source test - diff --git a/configs/config.py b/configs/config.py index af7f991..f0cfbf2 100644 --- a/configs/config.py +++ b/configs/config.py @@ -9,16 +9,18 @@ from configs.configs import CONFIGS class AppConfig: def __init__(self): - self.config = Dynaconf(settings_files=[ - "/app/configs/main.json", - "/app/configs/sources.json" - ]) - + self.refresh() connect( db=CONFIGS['db']['name'], host="mongodb://{host}:27017/{database}".format(host=CONFIGS['db']['host'], database=CONFIGS['db']['name']) ) - + + def refresh(self): + self.config = Dynaconf(settings_files=[ + "/app/configs/main.json", + "/app/configs/sources.json" + ]) + def get_bulk_insert_limit(self): if not self.config.bulk_limit: return 1 @@ -40,6 +42,7 @@ class AppConfig: } r = requests.get(CONFIGS['application_credentials']['api_url'] + "sources", headers=headers) if r.status_code != 200: + raise Exception('Bad app response') new_config = {"sources": {}} @@ -48,5 +51,7 @@ class AppConfig: with open("./configs/sources.json", "w") as outfile: outfile.write(json.dumps(new_config)) + + self.refresh() config = AppConfig() \ No newline at end of file diff --git a/update.py b/update.py index eecdbdb..3edb210 100644 --- a/update.py +++ b/update.py @@ -34,14 +34,17 @@ class Updater: config.update_sources() def do_action(self): + print("Start Updater"); if self.args.config: + print("Start Configure") self.update_config() return if not self.is_source_exists(self.args.source): print("This source not exists, list of sources: " + ', '.join(config.get_sources_list())) return - + + print("Start source update") self.parse_source(self.args.source)