MCPcopy
hub / github.com/caddyserver/caddy / stopAdminServer

Function stopAdminServer

admin.go:738–754  ·  view source on GitHub ↗
(srv *http.Server)

Source from the content-addressed store, hash-verified

736}
737
738func stopAdminServer(srv *http.Server) error {
739 if srv == nil {
740 return fmt.Errorf("no admin server")
741 }
742 timeout := 10 * time.Second
743 ctx, cancel := context.WithTimeoutCause(context.Background(), timeout, fmt.Errorf("stopping admin server: %ds timeout", int(timeout.Seconds())))
744 defer cancel()
745 err := srv.Shutdown(ctx)
746 if err != nil {
747 if cause := context.Cause(ctx); cause != nil && errors.Is(err, context.DeadlineExceeded) {
748 err = cause
749 }
750 return fmt.Errorf("shutting down admin server: %v", err)
751 }
752 Log().Named("admin").Info("stopped previous server", zap.String("address", srv.Addr))
753 return nil
754}
755
756// AdminRouter is a type which can return routes for the admin API.
757type AdminRouter interface {

Callers 4

replaceLocalAdminServerFunction · 0.85
replaceRemoteAdminServerFunction · 0.85
exitProcessFunction · 0.85

Calls 2

LogFunction · 0.85
StringMethod · 0.45

Tested by 1