MCPcopy Index your code
hub / github.com/coder/coder / Shutdown

Method Shutdown

coderd/aibridged/aibridged.go:168–192  ·  view source on GitHub ↗

Shutdown waits for all exiting in-flight requests to complete, or the context to expire, whichever comes first.

(ctx context.Context)

Source from the content-addressed store, hash-verified

166
167// Shutdown waits for all exiting in-flight requests to complete, or the context to expire, whichever comes first.
168func (s *Server) Shutdown(ctx context.Context) error {
169 var err error
170 s.shutdownOnce.Do(func() {
171 s.cancelFn()
172
173 // Wait for any outstanding connections to terminate.
174 s.wg.Wait()
175
176 select {
177 case <-ctx.Done():
178 s.logger.Warn(ctx, "graceful shutdown failed", slog.Error(ctx.Err()))
179 err = ctx.Err()
180 return
181 default:
182 }
183
184 s.logger.Info(ctx, "shutting down request pool")
185 if err = s.requestBridgePool.Shutdown(ctx); err != nil {
186 s.logger.Error(ctx, "request pool shutdown failed with error", slog.Error(err))
187 }
188
189 s.logger.Info(ctx, "gracefully shutdown")
190 })
191 return err
192}
193
194// Close shuts down the server with a timeout of 5s.
195func (s *Server) Close() error {

Callers 1

CloseMethod · 0.95

Calls 7

ErrMethod · 0.80
DoMethod · 0.65
WaitMethod · 0.65
ShutdownMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected