Skip to content

feat(codersdk/agentsdk): add StartupLogsSender and StartupLogsWriter #8129

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
Prev Previous commit
Next Next commit
improve documentatiaon
  • Loading branch information
mafredri committed Jun 21, 2023
commit c80755eed225b4c10460b9e834de5e12c756dab2
8 changes: 4 additions & 4 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,11 @@ func (a *agent) runScript(ctx context.Context, lifecycle, script string) (err er
var stdout, stderr io.Writer = fileWriter, fileWriter
if lifecycle == "startup" {
send, flushAndClose := agentsdk.StartupLogsSender(a.client.PatchStartupLogs, logger)
// If ctx is canceled here (or in a writer below), we may be
// discarding logs, but that's okay because we're shutting down
// anyway. We could consider creating a new context here if we
// want better control over flush during shutdown.
defer func() {
// If ctx is canceled here, we may be discarding logs, but
// that's okay because we're shutting down anyway. We could
// consider creating a new context here if we want to
// improve flush during shutdown.
if err := flushAndClose(ctx); err != nil {
logger.Warn(ctx, "flush startup logs failed", slog.Error(err))
}
Expand Down