mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
chore: Refactor CLI.py to use database instances for API calls
This commit refactors the CLI.py file to use the database instances for API calls instead of relying on the nginx server or the Linux integration. By iterating over the database instances, the APIs are now created dynamically based on the hostname and port of each instance. This change ensures that the API calls are made directly to the correct database instance, improving the reliability and performance of the application.
This commit is contained in:
parent
93f9b53a55
commit
761dfb807d
1 changed files with 2 additions and 10 deletions
|
|
@ -180,17 +180,9 @@ class CLI(ApiCaller):
|
|||
self.__logger.error("USE_REDIS is set to yes but REDIS_HOST or REDIS_SENTINEL_HOSTS is not set, disabling redis")
|
||||
self.__use_redis = False
|
||||
|
||||
if Path(sep, "usr", "sbin", "nginx").exists() or self.__integration == "Linux":
|
||||
return super().__init__(
|
||||
[
|
||||
API(
|
||||
f"http://127.0.0.1:{self.__get_variable('API_HTTP_PORT', '5000')}",
|
||||
host=self.__get_variable("API_SERVER_NAME", "bwapi"),
|
||||
)
|
||||
]
|
||||
)
|
||||
super().__init__()
|
||||
self.auto_setup(self.__integration)
|
||||
for db_instance in self.__db.get_instances():
|
||||
self.apis.append(API(f"http://{db_instance['hostname']}:{db_instance['port']}", db_instance["server_name"]))
|
||||
|
||||
def __get_variable(self, variable: str, default: Optional[Any] = None) -> Optional[str]:
|
||||
return getenv(variable, self.__variables.get(variable, default))
|
||||
|
|
|
|||
Loading…
Reference in a new issue