-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (27 loc) · 965 Bytes
/
main.py
File metadata and controls
38 lines (27 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import sys
from nomad_api import serve, serve_in_thread
from telegram_bot import NomadBot
def _render_foreground_http_api() -> bool:
"""If Render runs `python main.py` with no flags, keep the process alive with the Nomad HTTP server (health checks)."""
if (os.environ.get("RENDER") or "").strip().lower() != "true":
return False
# `python main.py` → argv is only the script path; any extra token is --cli, --mcp, etc.
return len(sys.argv) == 1
def main() -> None:
if _render_foreground_http_api():
serve()
return
if len(sys.argv) > 1 and sys.argv[1] == "--cli":
from nomad_cli import main as cli_main
cli_main(sys.argv[2:] or ["self"])
return
if len(sys.argv) > 1 and sys.argv[1] == "--mcp":
from nomad_mcp import serve_stdio
serve_stdio()
return
serve_in_thread()
bot = NomadBot()
bot.run()
if __name__ == "__main__":
main()