Files
kls/main.go
Kyle Isom 06d469abaf restore $PORT support, remove explicit ports mapping
The MCP agent assigns its own host port and sets $PORT. The app must
listen on $PORT for mc-proxy to reach it. Explicit Podman port mappings
in the service definition are ignored by the agent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 17:01:29 -07:00

45 lines
807 B
Go

package main
import (
"context"
"flag"
"log"
"net"
"net/http"
"os"
"git.wntrmute.dev/kyle/goutils/config"
"git.wntrmute.dev/kyle/goutils/die"
"git.wntrmute.dev/kyle/kls/links"
)
var defaultConfigFile = config.DefaultConfigPath("kls", "kls.conf")
func main() {
cfgFile := flag.String("f", defaultConfigFile, "`path` to config file")
flag.Parse()
err := config.LoadFile(*cfgFile)
die.If(err)
ctx := context.Background()
db, err := links.Connect(ctx)
die.If(err)
srv := &server{db: db}
http.Handle("/", srv)
var addr string
if port := os.Getenv("PORT"); port != "" {
addr = ":" + port
} else {
addr = net.JoinHostPort(
config.Get("HTTP_ADDR"),
config.GetDefault("HTTP_PORT", "8000"),
)
}
log.Print("listening on ", addr)
log.Fatal(http.ListenAndServe(addr, nil))
}