package main import ( "log" "net/http" "os" "time" ) func main() { addr := envOr("LISTEN_ADDR", ":8084") handler, err := newHandler( envOr("CORE_RUNTIME_URL", "http://core-runtime:8080"), envOr("CONTINUITY_RUNTIME_URL", "http://continuity-runtime:8081"), envOr("COMMIT_RUNTIME_URL", "http://commit-runtime:8082"), // Core chat may spend several seconds on semantic interpretation and // local cognition. Keep the browser gateway alive long enough to return // the completed response instead of converting a successful core 201 // into a misleading 502. // A cold local model may need more than one short HTTP round-trip to // load on CPU. Keep the browser gateway aligned with the cognition // deadline instead of turning that wait into a false unavailable reply. &http.Client{Timeout: 90 * time.Second}, envOr("COGNITIVE_RUNTIME_URL", "http://cognitive-worker:8083"), envOr("AGENT_WORKER_URL", "http://agent-worker:8090"), ) if err != nil { log.Fatal(err) } server := &http.Server{ Addr: addr, Handler: handler, ReadHeaderTimeout: 5 * time.Second, IdleTimeout: 60 * time.Second, } log.Printf("creator-web listening on %s", addr) if err := server.ListenAndServe(); err != nil { log.Fatal(err) } } func envOr(name, fallback string) string { if value := os.Getenv(name); value != "" { return value } return fallback }