Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(cli): generate correctly named file in DumpHandler#12409

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 4 commits intomainfrommafredri/fix-dump-filename
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletioncli/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -149,7 +149,7 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {

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

logWriter := &lumberjackWriteCloseFixer{w: &lumberjack.Logger{
Filename: filepath.Join(logDir, "coder-agent.log"),
Expand Down
8 changes: 6 additions & 2 deletionscli/root.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -937,7 +937,7 @@ func (r *RootCmd) Verbosef(inv *clibase.Invocation, fmtStr string, args ...inter
// 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, name string) {
if runtime.GOOS == "windows" {
// free up the goroutine since it'll be permanently blocked anyways
return
Expand DownExpand Up@@ -992,7 +992,11 @@ func DumpHandler(ctx context.Context) {
if err != nil {
dir = os.TempDir()
}
fpath := filepath.Join(dir, fmt.Sprintf("coder-agent-%s.dump", time.Now().Format("2006-01-02T15:04:05.000Z")))
// Make the time filesystem-safe, for example ":" is not
// permitted on many filesystems. Note that Z here only appends
// Z to the string, it does not actually change the time zone.
filesystemSafeTime := time.Now().UTC().Format("2006-01-02T15-04-05.000Z")
fpath := filepath.Join(dir, fmt.Sprintf("coder-%s-%s.dump", name, filesystemSafeTime))
_, _ = fmt.Fprintf(os.Stderr, "writing dump to %q\n", fpath)

f, err := os.Create(fpath)
Expand Down
2 changes: 1 addition & 1 deletioncli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -289,7 +289,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
cliui.Warnf(inv.Stderr, "YAML support is experimental and offers no compatibility guarantees.")
}

go DumpHandler(ctx)
go DumpHandler(ctx, "coderd")

// Validate bind addresses.
if vals.Address.String() != "" {
Expand Down
2 changes: 1 addition & 1 deletionenterprise/cli/proxyserver.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
defer topCancel()
closers.Add(topCancel)

go cli.DumpHandler(ctx)
go cli.DumpHandler(ctx, "workspace-proxy")

cli.PrintLogo(inv, "Coder Workspace Proxy")
logger, logCloser, err := clilog.New(clilog.FromDeploymentValues(cfg)).Build(inv)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp