File size: 1,525 Bytes
ddbc1ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
import os


def main() -> None:
    try:
        import uvicorn
    except ImportError as exc:
        print(f"[openenv-server] uvicorn not installed: {exc}. Skipping OpenEnv server.")
        return

    try:
        from openenv.core import create_app
    except Exception as exc:
        print(f"[openenv-server] openenv.core unavailable ({exc}). Skipping OpenEnv server.")
        return

    from core.lifestack_env import LifeStackEnv, LifeStackAction, LifeStackObservation

    host = os.getenv("OPENENV_HOST", "0.0.0.0")
    port = int(os.getenv("OPENENV_PORT", "8000"))
    max_concurrent = int(os.getenv("OPENENV_MAX_SESSIONS", "4"))

    os.environ.setdefault("ENABLE_WEB_INTERFACE", "true")

    try:
        app = create_app(
            env=LifeStackEnv,
            action_cls=LifeStackAction,
            observation_cls=LifeStackObservation,
            env_name="LifeStack Premium",
            max_concurrent_envs=max_concurrent,
        )
    except Exception as exc:
        print(f"[openenv-server] create_app failed ({exc}). Skipping OpenEnv server.")
        return

    print("\n" + "=" * 60)
    print("  LifeStack OpenEnv Server is ready!")
    print(f"  HTTP Endpoint : http://{host}:{port}")
    print(f"  Web Interface : http://{host}:{port}/web")
    print(f"  Documentation : http://{host}:{port}/docs")
    print(f"  Health check  : http://{host}:{port}/health")
    print("=" * 60 + "\n")

    uvicorn.run(app, host=host, port=port, log_level="info")


if __name__ == "__main__":
    main()