Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions agent/agent_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"math/rand/v2"
"net/http"
"os"
"sync"
"time"

Expand Down Expand Up @@ -424,6 +425,7 @@ func (a *AgentWorker) runPingLoop(ctx context.Context, idleMonitor *IdleMonitor)
// But only terminate if everyone else is also idle
if idleMonitor.Idle() {
a.logger.Info("All agents have been idle for %v. Disconnecting...", disconnectAfterIdleTimeout)
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_REASON", "IDLE")
return nil
}
a.logger.Debug("Agent has been idle for %.f seconds, but other agents haven't",
Expand Down
8 changes: 8 additions & 0 deletions clicommand/agent_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,9 +1377,17 @@ func handlePoolSignals(ctx context.Context, l logger.Logger, pool *agent.AgentPo
switch sig {
case syscall.SIGQUIT:
l.Debug("Received signal `%s`", sig.String())
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_REASON", "SIGNAL")
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_SIGNAL", "SIGQUIT")
pool.Stop(false)
case syscall.SIGTERM, syscall.SIGINT:
l.Debug("Received signal `%s`", sig.String())
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_REASON", "SIGNAL")
if sig == syscall.SIGTERM {
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_SIGNAL", "SIGTERM")
} else {
os.Setenv("BUILDKITE_AGENT_SHUTDOWN_SIGNAL", "SIGINT")
}
if interruptCount == 0 {
interruptCount++
l.Info("Received CTRL-C, send again to forcefully kill the agent(s)")
Expand Down