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
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

feat: write agent output to a temporary file#422

Merged
jawnsy merged 3 commits intomainfromjawnsy/ch16783/coder-agent-tee
Sep 2, 2021
Merged
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
19 changes: 15 additions & 4 deletionsinternal/cmd/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import (
"net/url"
"os"
"os/signal"
"path/filepath"
"syscall"

// We use slog here since agent runs in the background and we can benefit
Expand DownExpand Up@@ -48,10 +49,20 @@ coder agent start
coder agent start --coder-url https://my-coder.com --token xxxx-xxxx
`,
RunE: func(cmd *cobra.Command, args []string) error {
var (
ctx = cmd.Context()
log = slog.Make(sloghuman.Sink(os.Stderr)).Leveled(slog.LevelDebug)
)
ctx := cmd.Context()
sinks := []slog.Sink{
sloghuman.Sink(os.Stderr),
}

file, err := os.OpenFile(filepath.Join(os.TempDir(), "coder-agent.log"), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

it didn't seem like the file we write needs to be hidden, so I made it a not-dotfile

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should be consistent for the other log files in that case

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Which other log files do we have? I think just a code-server one right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

code-server and envagent, they're in environment_stages.go

if err == nil && file != nil {
sinks = append(sinks, sloghuman.Sink(file))
}

log := slog.Make(sinks...).Leveled(slog.LevelDebug)
if err != nil {
log.Info(ctx, "failed to open agent log file", slog.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should this be anerror log?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

maybe, but I don't expect it to happen for coder workspaces and everything would be logged to our console anyways

coadler reacted with thumbs up emoji
}
if coderURL == "" {
var ok bool
coderURL, ok = os.LookupEnv("CODER_URL")
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp