Skip to content

Commit

Permalink
Merge pull request elastic#48 from tsg/fix_handle_signals
Browse files Browse the repository at this point in the history
Fix handle signals.
  • Loading branch information
ruflin committed Sep 3, 2015
2 parents e4ee23a + 189d9f3 commit 5498ed9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions beat/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package beat
import (
"flag"
"fmt"
"os"
"runtime"

"github.com/elastic/libbeat/cfgfile"
"github.com/elastic/libbeat/logp"
"github.com/elastic/libbeat/outputs"
"github.com/elastic/libbeat/publisher"
"github.com/elastic/libbeat/service"
"os"
"runtime"
)

// Beater interface that every beat must use
Expand Down Expand Up @@ -103,11 +104,14 @@ func (b *Beat) Run() {
}
service.BeforeRun()

// Callback is called if the processes is asked to stop.
// This needs to be called before the main loop is started so that
// it can register the signals that stop or query (on Windows) the loop.
service.HandleSignals(b.BT.Stop)

// Run beater specific stuff
b.BT.Run(b)

// Function called in case of beater stop
service.HandleSignals(b.BT.Stop)
service.Cleanup()

logp.Debug("main", "Cleanup")
Expand Down

0 comments on commit 5498ed9

Please sign in to comment.