Skip to content

Commit fa64c58

Browse files
authored
chore: Export all functions used by server cmd (#7118)
* chore: Export all functions used by server cmd Required to make workspace proxy cmd * Factor out httpservers and tracer
1 parent 87fe16c commit fa64c58

File tree

3 files changed

+242
-192
lines changed

3 files changed

+242
-192
lines changed

cli/agent.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
8888
ctx, stopNotify := signal.NotifyContext(ctx, InterruptSignals...)
8989
defer stopNotify()
9090

91-
// dumpHandler does signal handling, so we call it after the
91+
// DumpHandler does signal handling, so we call it after the
9292
// reaper.
93-
go dumpHandler(ctx)
93+
go DumpHandler(ctx)
9494

9595
ljLogger := &lumberjack.Logger{
9696
Filename: filepath.Join(logDir, "coder-agent.log"),
@@ -119,7 +119,7 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
119119
// Enable pprof handler
120120
// This prevents the pprof import from being accidentally deleted.
121121
_ = pprof.Handler
122-
pprofSrvClose := serveHandler(ctx, logger, nil, pprofAddress, "pprof")
122+
pprofSrvClose := ServeHandler(ctx, logger, nil, pprofAddress, "pprof")
123123
defer pprofSrvClose()
124124
// Do a best effort here. If this fails, it's not a big deal.
125125
if port, err := urlPort(pprofAddress); err == nil {
@@ -262,7 +262,7 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
262262
return cmd
263263
}
264264

265-
func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
265+
func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
266266
logger.Debug(ctx, "http server listening", slog.F("addr", addr), slog.F("name", name))
267267

268268
// ReadHeaderTimeout is purposefully not enabled. It caused some issues with

cli/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
711711
return h.transport.RoundTrip(req)
712712
}
713713

714-
// dumpHandler provides a custom SIGQUIT and SIGTRAP handler that dumps the
714+
// DumpHandler provides a custom SIGQUIT and SIGTRAP handler that dumps the
715715
// stacktrace of all goroutines to stderr and a well-known file in the home
716716
// directory. This is useful for debugging deadlock issues that may occur in
717717
// production in workspaces, since the default Go runtime will only dump to
@@ -723,7 +723,7 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
723723
// A SIGQUIT handler will not be registered if GOTRACEBACK=crash.
724724
//
725725
// On Windows this immediately returns.
726-
func dumpHandler(ctx context.Context) {
726+
func DumpHandler(ctx context.Context) {
727727
if runtime.GOOS == "windows" {
728728
// free up the goroutine since it'll be permanently blocked anyways
729729
return

0 commit comments

Comments
 (0)