Merge branch 'master' of ssh://github.com/micro/go-micro
This commit is contained in:
commit
61dd2b8489
@ -645,6 +645,10 @@ func (g *grpcServer) Register() error {
|
||||
opts = append(opts, broker.Queue(queue))
|
||||
}
|
||||
|
||||
if cx := sb.Options().Context; cx != nil {
|
||||
opts = append(opts, broker.SubscribeContext(cx))
|
||||
}
|
||||
|
||||
if !sb.Options().AutoAck {
|
||||
opts = append(opts, broker.DisableAutoAck())
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ type Options struct {
|
||||
|
||||
// Static directory
|
||||
StaticDir string
|
||||
|
||||
Signal bool
|
||||
}
|
||||
|
||||
func newOptions(opts ...Option) Options {
|
||||
@ -59,6 +61,7 @@ func newOptions(opts ...Option) Options {
|
||||
StaticDir: DefaultStaticDir,
|
||||
Service: micro.NewService(),
|
||||
Context: context.TODO(),
|
||||
Signal: true,
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
@ -242,3 +245,12 @@ func RegisterCheck(fn func(context.Context) error) Option {
|
||||
o.RegisterCheck = fn
|
||||
}
|
||||
}
|
||||
|
||||
// HandleSignal toggles automatic installation of the signal handler that
|
||||
// traps TERM, INT, and QUIT. Users of this feature to disable the signal
|
||||
// handler, should control liveness of the service through the context.
|
||||
func HandleSignal(b bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Signal = b
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +383,9 @@ func (s *service) Run() error {
|
||||
go s.run(ex)
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT)
|
||||
if s.opts.Signal {
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT)
|
||||
}
|
||||
|
||||
select {
|
||||
// wait on kill signal
|
||||
|
Loading…
x
Reference in New Issue
Block a user