Skip to content

Commit

Permalink
Monitor more signals for debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
keithpitt committed May 20, 2014
1 parent b2bb6bd commit 7e1e83e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion buildbox/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,32 @@ func (a *Agent) Setup() {
func (a *Agent) MonitorSignals() {
// Handle signals
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGUSR2)

// Monitor a heap of different signals for debugging purposes. Only
// some of them are used.
signal.Notify(signals, os.Interrupt,
syscall.SIGHUP,
syscall.SIGTERM,
syscall.SIGQUIT,
syscall.SIGINT,
syscall.SIGUSR2)

go func() {
// This will block until a signal is sent
sig := <-signals

log.Printf("Received signal `%s`", sig.String())

// Only monitor certain signals
if sig != syscall.SIGINT && sig != syscall.SIGUSR2 {
log.Printf("Ignoring signal `%s`", sig.String())

// Start monitoring signals again
a.MonitorSignals()

return
}

// If the agent isn't running a job, exit right away
if a.Job == nil {
log.Printf("No jobs running. Exiting...")
Expand Down
2 changes: 1 addition & 1 deletion buildbox/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package buildbox

const (
Version = "0.2-beta.1"
Version = "0.2-beta.2"
)

0 comments on commit 7e1e83e

Please sign in to comment.