MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / StartServer

Method StartServer

imgproxy.go:193–221  ·  view source on GitHub ↗

StartServer runs the imgproxy server. This function blocks until the context is cancelled. If hasStarted is not nil, it will be notified with the server address once the server is ready or about to be ready to accept requests.

(ctx context.Context, hasStarted chan net.Addr)

Source from the content-addressed store, hash-verified

191// If hasStarted is not nil, it will be notified with the server address once
192// the server is ready or about to be ready to accept requests.
193func (i *Imgproxy) StartServer(ctx context.Context, hasStarted chan net.Addr) error {
194 go i.startMemoryTicker(ctx)
195
196 ctx, cancel := context.WithCancel(ctx)
197
198 if err := i.monitoring.StartPrometheus(cancel); err != nil {
199 return err
200 }
201
202 router, err := i.BuildRouter()
203 if err != nil {
204 return err
205 }
206
207 s, err := server.Start(cancel, router)
208 if err != nil {
209 return err
210 }
211 defer s.Shutdown(context.Background())
212
213 if hasStarted != nil {
214 hasStarted <- s.Addr
215 close(hasStarted)
216 }
217
218 <-ctx.Done()
219
220 return nil
221}
222
223// Close gracefully shuts down the imgproxy instance
224func (i *Imgproxy) Close(ctx context.Context) {

Callers 2

runFunction · 0.45
startServerMethod · 0.45

Calls 6

startMemoryTickerMethod · 0.95
BuildRouterMethod · 0.95
StartFunction · 0.92
StartPrometheusMethod · 0.80
ShutdownMethod · 0.80
BackgroundMethod · 0.80

Tested by

no test coverage detected