mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Merge branch 'dev' into staging
This commit is contained in:
commit
5be6e07967
2 changed files with 27 additions and 17 deletions
|
|
@ -817,20 +817,22 @@ def instances():
|
|||
"restart",
|
||||
):
|
||||
return redirect_flash_error("Missing operation parameter on /instances.", "instances")
|
||||
app.config["RELOADING"] = True
|
||||
app.config["LAST_RELOAD"] = time()
|
||||
Thread(
|
||||
target=manage_bunkerweb,
|
||||
name="Reloading instances",
|
||||
args=("instances", request.form["INSTANCE_ID"]),
|
||||
kwargs={"operation": request.form["operation"]},
|
||||
).start()
|
||||
|
||||
manage_bunkerweb("instances", request.form["INSTANCE_ID"], operation=request.form["operation"])
|
||||
|
||||
for f in app.config["TO_FLASH"]:
|
||||
if f["type"] == "error":
|
||||
flash(f["content"], "error")
|
||||
else:
|
||||
flash(f["content"])
|
||||
|
||||
app.config["TO_FLASH"].clear()
|
||||
|
||||
sleep(3)
|
||||
|
||||
return redirect(url_for("instances"))
|
||||
return redirect(
|
||||
url_for(
|
||||
"loading",
|
||||
next=url_for("instances"),
|
||||
message=(f"{request.form['operation'].title()}ing" if request.form["operation"] != "stop" else "Stopping") + " instance",
|
||||
)
|
||||
)
|
||||
|
||||
# Display instances
|
||||
instances = app.config["INSTANCES"].get_instances()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from selenium.common.exceptions import TimeoutException, WebDriverException
|
|||
from wizard import DRIVER
|
||||
from base import TEST_TYPE
|
||||
from utils import access_page, assert_button_click, safe_get_element, wait_for_service
|
||||
from time import sleep
|
||||
|
||||
exit_code = 0
|
||||
|
||||
|
|
@ -21,9 +22,14 @@ try:
|
|||
|
||||
try:
|
||||
form = safe_get_element(DRIVER, By.XPATH, "//form[starts-with(@id, 'form-instance-')]")
|
||||
except TimeoutException:
|
||||
log_exception("No instance form found, exiting ...")
|
||||
exit(1)
|
||||
except:
|
||||
if retries >= 3:
|
||||
exit(1)
|
||||
retries += 1
|
||||
log_warning("No instance form found, retrying ...")
|
||||
sleep(2)
|
||||
DRIVER.refresh()
|
||||
continue
|
||||
|
||||
try:
|
||||
access_page(DRIVER, f"//form[starts-with(@id, 'form-instance-')]//button[@value='{action}']", "instances", False)
|
||||
|
|
@ -45,7 +51,9 @@ try:
|
|||
|
||||
try:
|
||||
assert_button_click(DRIVER, f"//form[starts-with(@id, 'form-instance-')]//button[@value='{action}']")
|
||||
safe_get_element(DRIVER, By.XPATH, "//form[starts-with(@id, 'form-instance-')]")
|
||||
log_info(f"Clicked on stop button, waiting 5s ...")
|
||||
sleep(5)
|
||||
safe_get_element(DRIVER, By.XPATH, "//form[starts-with(@id, 'form-instance-')]", error=True)
|
||||
log_exception("Instance was not stopped successfully, exiting ...")
|
||||
exit(1)
|
||||
except (TimeoutException, WebDriverException):
|
||||
|
|
|
|||
Loading…
Reference in a new issue