Files
kls/main.go
Kyle Isom 0ecea29413 remove $PORT, use config for listen port
MCP's pasta port mapping maps host:randomport to container:routeport.
The app must listen on the route's port (443) inside the container,
configured via HTTP_PORT in kls.conf.

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

39 lines
704 B
Go

package main
import (
"context"
"flag"
"log"
"net"
"net/http"
"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)
addr := net.JoinHostPort(
config.Get("HTTP_ADDR"),
config.GetDefault("HTTP_PORT", "8000"),
)
log.Print("listening on ", addr)
log.Fatal(http.ListenAndServe(addr, nil))
}