Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Jan 30, 2023

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jan 30, 2023

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.

@mafredri mafredri self-assigned this Jan 30, 2023
@mafredri mafredri requested review from kylecarbs and mtojek January 30, 2023 10:42
@@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
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).

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

👍

Base automatically changed from mafredri/feat-handle-agent-signals to main January 30, 2023 13:59
@mafredri mafredri force-pushed the mafredri/feat-agent-log-dir branch from 580fda2 to 284b7fd Compare January 30, 2023 14:01
@mafredri mafredri merged commit f4d6afb into main Jan 30, 2023
@mafredri mafredri deleted the mafredri/feat-agent-log-dir branch January 30, 2023 16:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants