"""Container entry point: boot the agent, then serve the Streamlit app. Equivalent to `streamlit run app.py ...` (the Streamlit CLI runs its Tornado server in this same process), except that the agent's boot (schema check, stale-run sweep, scheduler, keep-alive) starts immediately on a background thread instead of waiting for the first page view. The Streamlit page's own boot() is then a no-op, because agent.autostart.boot_once is per-process. """ from __future__ import annotations import logging import os import sys logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s") log = logging.getLogger("run_space") def main() -> int: from agent import autostart autostart.start_in_background() log.info("agent boot started in background; serving Streamlit") from streamlit.web import cli as stcli port = os.environ.get("PORT", "7860") sys.argv = [ "streamlit", "run", "app.py", f"--server.port={port}", "--server.address=0.0.0.0", "--server.headless=true", "--server.fileWatcherType=none", ] return stcli.main() # runs the server in-process; returns on shutdown if __name__ == "__main__": sys.exit(main())