Skip to content

Commit

Permalink
fix: don't wait for process to terminate on timeout
Browse files Browse the repository at this point in the history
Allow longer start (5 minutes).

Signed-off-by: Sylvain Leclerc <[email protected]>
  • Loading branch information
sylvlecl committed Oct 4, 2024
1 parent 998079f commit 0df83b0
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import textwrap
import time
import webbrowser
from abc import abstractclassmethod, ABC, abstractmethod
from contextlib import suppress
from difflib import SequenceMatcher
from pathlib import Path
Expand Down Expand Up @@ -279,28 +280,17 @@ def start_server(self):
args = [self.server_path]
server_process = subprocess.Popen(
args=args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=self.target_dir,
shell=True,
)
self.update_progress(50)

if not server_process.poll():
logger.info("Server is starting up ...")
else:
stdout, stderr = server_process.communicate()
msg = f"The server unexpectedly stopped running. (code {server_process.returncode})"
logger.info(msg)
logger.info(f"Server unexpectedly stopped.\nstdout: {stdout}\nstderr: {stderr}")
raise InstallError(msg)

nb_attempts = 0
max_attempts = 30

max_attempts = 300
while nb_attempts < max_attempts:
logger.info(f"Waiting for server start (attempt #{nb_attempts})...")
if server_process.poll() is not None:
raise InstallError("Server failed to start, please check server logs.")
with suppress(httpx.RequestError):
res = httpx.get(SERVER_ADDRESS + "/health", timeout=1)
if res.status_code == 200:
Expand All @@ -309,11 +299,7 @@ def start_server(self):
time.sleep(1)
nb_attempts += 1
else:
stdout, stderr = server_process.communicate()
msg = "The server didn't start in time"
logger.error(msg)
logger.error(f"stdout: {stdout}\nstderr: {stderr}")
raise InstallError(msg)
raise InstallError("Server didn't start in time, please check server logs.")

def open_browser(self):
"""
Expand Down

0 comments on commit 0df83b0

Please sign in to comment.