cmd/stepd: Don't copy lock value

This commit is contained in:
Sasha Koshka 2025-07-07 07:53:01 -04:00
parent 64fb80734d
commit 48e8c2d4f0

View File

@ -209,8 +209,10 @@ func main () {
// set up the HTTP server // set up the HTTP server
httpServer := httpServerRoutine { httpServer := httpServerRoutine {
Addr: config.Get("http.address"), Server: &http.Server {
Handler: &handler, Addr: config.Get("http.address"),
Handler: &handler,
},
} }
// set up the trimming routine // set up the trimming routine
@ -241,21 +243,22 @@ func main () {
} }
} }
type httpServerRoutine http.Server type httpServerRoutine struct {
*http.Server
}
func (this *httpServerRoutine) Run (ctx context.Context) error { func (this *httpServerRoutine) Run (ctx context.Context) error {
ctx, done := context.WithCancel(ctx) ctx, done := context.WithCancel(ctx)
defer done() defer done()
server := http.Server(*this)
go func () { go func () {
<- ctx.Done() <- ctx.Done()
shutdownCtx, done := context.WithTimeout ( shutdownCtx, done := context.WithTimeout (
context.Background(), context.Background(),
16 * time.Second) 16 * time.Second)
defer done() defer done()
server.Shutdown(shutdownCtx) this.Server.Shutdown(shutdownCtx)
} () } ()
err := server.ListenAndServe() err := this.Server.ListenAndServe()
if ctx.Err() != nil { if ctx.Err() != nil {
return ctx.Err() return ctx.Err()
} }