debugserver

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package debugserver hosts the opt-in profiling endpoint.

It exists because of what `http.ListenAndServe(addr, nil)` does not do. That call serves the process-wide default mux and returns only when the server fails, so there was no server value to shut down and no way to say when it had stopped. Turning pprof off in the config did not close the listener that was already running: the reload built the next generation while the previous one still held 127.0.0.1:6060, and if that generation had profiling on too, it raced the port and lost.

Serving the default mux is its own problem. Any package anywhere in the build that registers a handler in an init function — which is exactly how net/http/pprof itself works — becomes reachable on the profiling port without anyone deciding that it should be. The handlers here are named one by one instead, so what is on this port is what this file says is on it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, addr string) error

Serve runs the profiling endpoint on addr until ctx ends, then releases the port before returning. A context that is already over binds nothing.

func ServeListener

func ServeListener(ctx context.Context, listener net.Listener) error

ServeListener is Serve on a listener the caller already opened. It owns the listener from here: it is closed by the time this returns, whichever way the server ended.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL