Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch "dev" into branch "staging" #1282

Merged
merged 6 commits into from
Jun 17, 2024
Prev Previous commit
Next Next commit
chore: Improve Config.py by handling invalid multisite settings and a…
…dding debug logs
  • Loading branch information
TheophileDiot committed Jun 17, 2024
commit 52c37d72d11e25ecdcee70eb60d5a20a24b0213f
11 changes: 9 additions & 2 deletions src/autoconf/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ def __get_full_env(self) -> dict:
if not server_name:
continue
for variable, value in service.items():
if self._db.is_setting(variable, multisite=True):
config[f"{server_name}_{variable}"] = value
if variable.startswith("CUSTOM_CONF") or not variable.isupper():
continue
if not self._db.is_setting(variable, multisite=True):
self.__logger.warning(f"Variable {variable}: {value} is not a valid multisite setting, ignoring it")
continue
config[f"{server_name}_{variable}"] = value
config["SERVER_NAME"] += f" {server_name}"
config["SERVER_NAME"] = config["SERVER_NAME"].strip()
return config
Expand Down Expand Up @@ -134,13 +138,15 @@ def apply(

# update instances in database
if "instances" in changes:
self.__logger.debug(f"Updating instances in database: {self.__instances}")
err = self._db.update_instances(self.__instances, changed=False)
if err:
self.__logger.error(f"Failed to update instances: {err}")

# save config to database
changed_plugins = []
if "config" in changes:
self.__logger.debug(f"Saving config in database: {self.__config}")
err = self._db.save_config(self.__config, "autoconf", changed=False)
if isinstance(err, str):
success = False
Expand All @@ -149,6 +155,7 @@ def apply(

# save custom configs to database
if "custom_configs" in changes:
self.__logger.debug(f"Saving custom configs in database: {custom_configs}")
err = self._db.save_custom_configs(custom_configs, "autoconf", changed=False)
if err:
success = False
Expand Down
Loading