Files
m 14c5d9e412
CI / test (push) Failing after 1m8s
CI / test (pull_request) Failing after 1m1s
Route creative image requests to media generation
2026-08-25 17:34:05 +03:00

48 lines
1.4 KiB
Go

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: 15 * time.Minute},
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
}