MCPcopy
hub / github.com/passteque/gluetun / Run

Method Run

internal/httpproxy/server.go:34–58  ·  view source on GitHub ↗
(ctx context.Context, errorCh chan<- error)

Source from the content-addressed store, hash-verified

32}
33
34func (s *Server) Run(ctx context.Context, errorCh chan<- error) {
35 server := http.Server{
36 Addr: s.address,
37 Handler: s.handler,
38 ReadHeaderTimeout: s.readHeaderTimeout,
39 ReadTimeout: s.readTimeout,
40 }
41 go func() {
42 <-ctx.Done()
43 const shutdownGraceDuration = 100 * time.Millisecond
44 shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
45 defer cancel()
46 if err := server.Shutdown(shutdownCtx); err != nil {
47 s.logger.Error("failed shutting down: " + err.Error())
48 }
49 }()
50 s.logger.Info("listening on " + s.address)
51 err := server.ListenAndServe()
52 s.internalWG.Wait()
53 if err != nil && ctx.Err() == nil {
54 errorCh <- err
55 } else {
56 errorCh <- nil
57 }
58}

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.65
InfoMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected