diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-02 07:41:33 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-02 07:41:33 +0200 |
| commit | b6c424b769b6f7d19c805327d59b1daa76f72285 (patch) | |
| tree | beb5d7a1325a0953b3442dd4817d27c3f8dd1a99 /internal/flamegraph/liveserver.go | |
| parent | e5409861c00e4334baa9ba75b277332ec14089ed (diff) | |
Add HTTP timeouts for flamegraph web servers
Diffstat (limited to 'internal/flamegraph/liveserver.go')
| -rw-r--r-- | internal/flamegraph/liveserver.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/flamegraph/liveserver.go b/internal/flamegraph/liveserver.go index 95063d0..801b841 100644 --- a/internal/flamegraph/liveserver.go +++ b/internal/flamegraph/liveserver.go @@ -8,6 +8,12 @@ import ( "time" ) +var liveServerTimeouts = serverTimeouts{ + readTimeout: 10 * time.Second, + writeTimeout: 5 * time.Minute, + idleTimeout: 60 * time.Second, +} + // ServeLive starts the live flamegraph HTTP server and blocks until ctx is canceled. func ServeLive(ctx context.Context, lt *LiveTrie, interval time.Duration) error { mux := http.NewServeMux() @@ -15,7 +21,7 @@ func ServeLive(ctx context.Context, lt *LiveTrie, interval time.Duration) error mux.HandleFunc("/events", handleSSE(lt, interval)) mux.HandleFunc("/reset", handleReset(lt)) mux.HandleFunc("/order", handleOrder(lt)) - return runServer(ctx, mux, func(hostname string, port int) { + return runServer(ctx, mux, liveServerTimeouts, func(hostname string, port int) { fmt.Printf("Live flamegraph available at http://%s:%d/\n", hostname, port) }) } |
