-
Notifications
You must be signed in to change notification settings - Fork 913
feat(agent): Allow specifying log directory via flag or env #5915
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
Conversation
@@ -582,7 +588,7 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error { | |||
} | |||
|
|||
a.logger.Info(ctx, "running startup script", slog.F("script", script)) | |||
writer, err := a.filesystem.OpenFile(filepath.Join(a.tempDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600) | |||
writer, err := a.filesystem.OpenFile(filepath.Join(a.logDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writer, err := a.filesystem.OpenFile(filepath.Join(a.logDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600) | |
writer, err := a.filesystem.OpenFile(filepath.Join(a.logDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600) |
I'd want to rename this to coder-agent-startup-script.log
as well, for uniformity (needs docs updates and could be done in a separate PR if it sounds like a good idea).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
580fda2
to
284b7fd
Compare
This PR adds support for
--log-dir
and$CODER_AGENT_LOG_DIR
.This is useful for storing the logs in persistent storage. For instance in Docker containers
/tmp
can often be mounted as tmpfs, and this may have RAM implications and does not persist. Similarly it's currently not possible to run multiple agents on the same machine because they write to the same log.NOTE: That this PR targets another PR due to introduction of an additional log file.