mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Fix shenanigans with ApiCaller
This commit is contained in:
parent
ecb8090f70
commit
70139ca421
3 changed files with 19 additions and 16 deletions
|
|
@ -145,17 +145,17 @@ class JobScheduler(ApiCaller):
|
|||
reload = proc.returncode == 0
|
||||
if reload:
|
||||
self.__logger.info("Successfully reloaded nginx")
|
||||
else:
|
||||
self.__logger.error(
|
||||
f"Error while reloading nginx - returncode: {proc.returncode} - error: {proc.stderr.decode() if proc.stderr else 'Missing stderr'}"
|
||||
)
|
||||
return True
|
||||
self.__logger.error(
|
||||
f"Error while reloading nginx - returncode: {proc.returncode} - error: {proc.stderr.decode() if proc.stderr else 'Missing stderr'}"
|
||||
)
|
||||
else:
|
||||
self.__logger.info("Reloading nginx ...")
|
||||
reload = self.send_to_apis("POST", "/reload")
|
||||
reload = self.send_to_apis("POST", "/reload")[0]
|
||||
if reload:
|
||||
self.__logger.info("Successfully reloaded nginx")
|
||||
else:
|
||||
self.__logger.error("Error while reloading nginx")
|
||||
return True
|
||||
self.__logger.error("Error while reloading nginx")
|
||||
return reload
|
||||
|
||||
def __job_wrapper(self, path: str, plugin: str, name: str, file: str) -> int:
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ def healthcheck_job():
|
|||
api_caller.send_files(PRO_PLUGINS_PATH, "/pro_plugins")
|
||||
api_caller.send_files(join(sep, "etc", "nginx"), "/confs")
|
||||
api_caller.send_files(CACHE_PATH, "/cache")
|
||||
if api_caller.send_to_apis("POST", "/reload"):
|
||||
if api_caller.send_to_apis("POST", "/reload")[0]:
|
||||
LOGGER.info(f"Successfully reloaded instance {bw_instance.endpoint}")
|
||||
else:
|
||||
LOGGER.error(f"Error while reloading instance {bw_instance.endpoint}")
|
||||
|
|
@ -789,7 +789,9 @@ if __name__ == "__main__":
|
|||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
failed = not SCHEDULER.send_to_apis("POST", "/reload")
|
||||
failed = not SCHEDULER.send_to_apis("POST", "/reload")[
|
||||
0
|
||||
] # TODO: Check error message so we don't try to send failover if host is unreachable
|
||||
elif INTEGRATION == "Linux":
|
||||
# Reload nginx
|
||||
LOGGER.info("Reloading nginx ...")
|
||||
|
|
@ -832,7 +834,8 @@ if __name__ == "__main__":
|
|||
for thread in tmp_threads:
|
||||
thread.join()
|
||||
|
||||
SCHEDULER.send_to_apis("POST", "/reload")
|
||||
if not SCHEDULER.send_to_apis("POST", "/reload")[0]:
|
||||
LOGGER.error("Error while reloading bunkerweb with failover configuration, skipping ...")
|
||||
else:
|
||||
LOGGER.info("Successfully reloaded bunkerweb")
|
||||
# Update the failover path with the working configuration
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class Instance:
|
|||
|
||||
def reload(self) -> str:
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/reload")
|
||||
result = self.apiCaller.send_to_apis("POST", "/reload")[0]
|
||||
except BaseException as e:
|
||||
return f"Can't reload {self.hostname}: {e}"
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ class Instance:
|
|||
def start(self) -> str:
|
||||
raise NotImplementedError("Method not implemented yet")
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/start")
|
||||
result = self.apiCaller.send_to_apis("POST", "/start")[0]
|
||||
except BaseException as e:
|
||||
return f"Can't start {self.hostname}: {e}"
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class Instance:
|
|||
|
||||
def stop(self) -> str:
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/stop")
|
||||
result = self.apiCaller.send_to_apis("POST", "/stop")[0]
|
||||
except BaseException as e:
|
||||
return f"Can't stop {self.hostname}: {e}"
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class Instance:
|
|||
|
||||
def restart(self) -> str:
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/restart")
|
||||
result = self.apiCaller.send_to_apis("POST", "/restart")[0]
|
||||
except BaseException as e:
|
||||
return f"Can't restart {self.hostname}: {e}"
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ class Instance:
|
|||
|
||||
def ban(self, ip: str, exp: float, reason: str) -> str:
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/ban", data={"ip": ip, "exp": exp, "reason": reason})
|
||||
result = self.apiCaller.send_to_apis("POST", "/ban", data={"ip": ip, "exp": exp, "reason": reason})[0]
|
||||
except BaseException as e:
|
||||
return f"Can't ban {ip} on {self.hostname}: {e}"
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ class Instance:
|
|||
|
||||
def unban(self, ip: str) -> str:
|
||||
try:
|
||||
result = self.apiCaller.send_to_apis("POST", "/unban", data={"ip": ip})
|
||||
result = self.apiCaller.send_to_apis("POST", "/unban", data={"ip": ip})[0]
|
||||
except BaseException as e:
|
||||
return f"Can't unban {ip} on {self.hostname}: {e}"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue