Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/InnoDev69/StockManager/llms.txt

Use this file to discover all available pages before exploring further.

StockManager exposes a single lightweight health check endpoint that returns an immediate 200 OK with a JSON body as soon as the server is accepting connections. It requires no authentication, makes no database queries, and carries no side effects — making it safe to call as frequently as a monitoring or orchestration system requires.

GET /api/health

Authentication: None required Request body: None Query parameters: None

Response

{"status": "Ok"}
FieldTypeValue
statusstringAlways "Ok" when the server is reachable

Example

curl http://127.0.0.1:5000/api/health
# {"status": "Ok"}

How StockManager uses this endpoint internally

When StockManager is launched as a desktop application, main.py starts the Waitress WSGI server on a background daemon thread and then calls wait_for_server() before opening the PyWebView window. That function attempts a raw TCP connection to 127.0.0.1:5000 in a tight loop and returns as soon as the port is reachable — or raises a RuntimeError after 15 seconds if the server never responds.
if not wait_for_server(FLASK_HOST, FLASK_PORT, timeout=15.0):
    raise RuntimeError("Waitress no respondió en 15 segundos.")
Once the check passes, the log records boot:server_ready with the elapsed milliseconds and the PyWebView window is created. This guarantees the UI never loads against a server that is still initialising.

Practical uses

Uptime monitoring

Point any HTTP-based uptime monitor (e.g. healthchecks.io, UptimeRobot, Grafana OnCall) at GET /api/health. A non-200 response or a connection timeout indicates the server process has stopped or become unresponsive.

Docker HEALTHCHECK

Add a HEALTHCHECK instruction to your Dockerfile so the container runtime can detect and restart an unhealthy StockManager instance automatically:
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s CMD curl -f http://localhost:5000/api/health || exit 1
OptionValueMeaning
--interval30sCheck every 30 seconds
--timeout5sMark unhealthy if no reply within 5 seconds
--start-period10sGive the container 10 seconds to initialise before failures count

CI/CD readiness gate

In a CI pipeline that spins up StockManager before running integration tests, poll this endpoint rather than using a fixed sleep:
echo "Waiting for StockManager..."
until curl -sf http://127.0.0.1:5000/api/health; do
  sleep 1
done
echo "Server ready — running tests"
pytest tests/integration/
In any automated deployment or test script, poll /api/health in a loop with a bounded retry count instead of relying on a fixed sleep delay. The endpoint responds the moment Waitress is ready, so polling eliminates unnecessary wait time and catches startup failures immediately.

Build docs developers (and LLMs) love