secure-messaging/go/cmd/sm-leaf/main.go
George Lambert f4da7ff446
Some checks are pending
ci / python (push) Waiting to run
ci / go (push) Waiting to run
S15: sm-leaf health HTTP, verae.sm.* acks, systemd unit
Loopback GET /health, nats-leaf:// rewrite, subject request-reply tests.
Do not replace pfc-py-admin. NpeRequired stays on the package surface.
2026-09-15 22:40:50 -04:00

39 lines
878 B
Go

// sm-leaf: in-process NATS core plus optional leaf to the Verae hub.
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
"github.com/marchon/secure-messaging/internal/leaf"
)
func main() {
hub := flag.String("hub", os.Getenv("SM_LEAF_HUB"), "leaf hub URL, e.g. nats://10.10.10.21:7422")
httpAddr := flag.String("http", getenv("SM_HTTP", "127.0.0.1:18783"), "loopback health HTTP")
flag.Parse()
n, err := leaf.Start(*hub)
if err != nil {
log.Fatal(err)
}
log.Printf("sm-leaf in-process nats %s hub=%q http=%s", n.Addr(), *hub, *httpAddr)
go func() {
if err := leaf.ServeHealth(*httpAddr); err != nil {
log.Printf("health: %v", err)
}
}()
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
<-ch
_ = n.Shutdown()
}
func getenv(k, d string) string {
if v := os.Getenv(k); v != "" {
return v
}
return d
}