Skip to content

chore: Export all functions used by server cmd #7118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
ctx, stopNotify := signal.NotifyContext(ctx, InterruptSignals...)
defer stopNotify()

// dumpHandler does signal handling, so we call it after the
// DumpHandler does signal handling, so we call it after the
// reaper.
go dumpHandler(ctx)
go DumpHandler(ctx)

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

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

// ReadHeaderTimeout is purposefully not enabled. It caused some issues with
Expand Down
4 changes: 2 additions & 2 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return h.transport.RoundTrip(req)
}

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