#!/usr/bin/python3
"""autodistd entry point.

Installed as /usr/bin/autodistd inside the buildvm container image. Started
via `docker exec <container> /usr/bin/autodistd`, kept resident by the
autodistd@.service systemd template unit on the docker host (see
systemd/autodistd@.service in this directory) -- not by anything running
inside the container itself.
"""
import os
import sys

_HERE = os.path.dirname(os.path.abspath(__file__))
for _candidate in ("/usr/share/autodist", _HERE):
    if _candidate not in sys.path:
        sys.path.insert(0, _candidate)

import uvicorn  # noqa: E402

if __name__ == "__main__":
    port = int(os.environ.get("AUTODISTD_PORT", "8021"))
    uvicorn.run("autodistd_app.api:app", host="0.0.0.0", port=port, log_level="info")
