do not block on start

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2018-06-09 23:05:01 -04:00
parent 5dace354b7
commit 23834a39fd
No known key found for this signature in database
GPG key ID: A519480096146526

View file

@ -3,14 +3,12 @@ package element
import (
"fmt"
"net"
"os"
"syscall"
"github.com/sirupsen/logrus"
)
// Start activates the GRPC listener as well as joins the cluster if specified and blocks until a SIGTERM or SIGINT is received
func (a *Agent) Start(signals chan os.Signal) error {
func (a *Agent) Start() error {
logrus.Infof("starting agent: grpc=%s:%d bind=%s:%d advertise=%s:%d",
a.config.AgentAddr,
a.config.AgentPort,
@ -45,18 +43,5 @@ func (a *Agent) Start(signals chan os.Signal) error {
logrus.Infof("joined %d peer(s)", n)
}
for {
select {
case s := <-signals:
switch s {
case syscall.SIGTERM, syscall.SIGINT:
logrus.Debug("shutting down")
if err := a.Shutdown(); err != nil {
return err
}
return nil
}
}
}
return nil
}