Skip to content
Merged
10 changes: 10 additions & 0 deletions packaging/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ http {
proxy_send_timeout 360000s;
proxy_read_timeout 360000s;
}

location /management {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job using the existing API 👍

client_max_body_size 16G;
proxy_pass http://localhost:9000;
proxy_http_version 1.1;

proxy_connect_timeout 360000s;
proxy_send_timeout 360000s;
proxy_read_timeout 360000s;
}
}
}

Expand Down
39 changes: 38 additions & 1 deletion python-client/giskard/commands/cli_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import time
from pathlib import Path
from typing import Optional
from urllib.parse import urlparse
Expand Down Expand Up @@ -91,6 +92,33 @@ def get_container(version=None, quit_if_not_exists=True) -> Optional[Container]:
return None


def _is_backend_ready(endpoint) -> bool:
try:
response = requests.get(endpoint)
response.raise_for_status()
return "UP" == response.json()["status"]
except KeyboardInterrupt:
raise click.Abort()
except BaseException:
return False


def _wait_backend_ready(port: int) -> bool:
endpoint = f"http://localhost:{port}/management/health"
backoff_time = 2
max_duration_second = 3 * 60
started_time = time.time()
up = False

while not up or time.time() - started_time > max_duration_second:
time.sleep(backoff_time)
up = _is_backend_ready(endpoint)
click.echo(".", nl=False)

click.echo(".")
return up


def _start(attached=False, version=None):
logger.info("Starting Giskard Server")

Expand All @@ -115,7 +143,16 @@ def _start(attached=False, version=None):
volumes={home_volume.name: {"bind": "/home/giskard/datadir", "mode": "rw"}},
)
container.start()
logger.info(f"Giskard Server {version} started. You can access it at http://localhost:{port}")

up = _wait_backend_ready(port)

if up:
logger.info(f"Giskard Server {version} started. You can access it at http://localhost:{port}")
else:
logger.warning(
"Giskard backend takes unusually long time to start, please check the logs with `giskard server "
"logs backend"
Copy link
Contributor

@andreybavt andreybavt Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a missing closing ` after "backend"

Suggested change
"logs backend"
"logs backend`"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or perhaps to make it even more readable you can break the long line before the giskard server logs backend command, for example after the first comma

)


def _check_downloaded(version: str):
Expand Down