Skip to content

feat: implement agent process management #9461

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 21 commits into from
Sep 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
defer first
  • Loading branch information
sreya committed Sep 15, 2023
commit 04ee5cb5b27e4b3cf2e904931fccac8e248f513d
18 changes: 9 additions & 9 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,15 +1282,6 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
var prioritizedProcs = []string{"coder agent"}

func (a *agent) manageProcessPriorityLoop(ctx context.Context) {
if val := a.envVars[EnvProcPrioMgmt]; val == "" || runtime.GOOS != "linux" {
a.logger.Debug(ctx, "process priority not enabled, agent will not manage process niceness/oom_score_adj ",
slog.F("env_var", EnvProcPrioMgmt),
slog.F("value", val),
slog.F("goos", runtime.GOOS),
)
return
}

defer func() {
if r := recover(); r != nil {
a.logger.Critical(ctx, "recovered from panic",
Expand All @@ -1300,6 +1291,15 @@ func (a *agent) manageProcessPriorityLoop(ctx context.Context) {
}
}()

if val := a.envVars[EnvProcPrioMgmt]; val == "" || runtime.GOOS != "linux" {
a.logger.Debug(ctx, "process priority not enabled, agent will not manage process niceness/oom_score_adj ",
slog.F("env_var", EnvProcPrioMgmt),
slog.F("value", val),
slog.F("goos", runtime.GOOS),
)
return
}

if a.processManagementTick == nil {
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
Expand Down