Harden process ring buffer and daemon/health shutdown behavior
This commit is contained in:
parent
2d68f89197
commit
8b0fe175b9
3 changed files with 16 additions and 3 deletions
|
|
@ -19,6 +19,10 @@ type RingBuffer struct {
|
|||
//
|
||||
// rb := process.NewRingBuffer(256)
|
||||
func NewRingBuffer(size int) *RingBuffer {
|
||||
if size <= 0 {
|
||||
size = 1
|
||||
}
|
||||
|
||||
return &RingBuffer{
|
||||
data: make([]byte, size),
|
||||
size: size,
|
||||
|
|
|
|||
|
|
@ -164,7 +164,9 @@ func (d *Daemon) Stop() error {
|
|||
|
||||
// Auto-unregister
|
||||
if d.opts.Registry != nil {
|
||||
_ = d.opts.Registry.Unregister(d.opts.RegistryEntry.Code, d.opts.RegistryEntry.Daemon)
|
||||
if err := d.opts.Registry.Unregister(d.opts.RegistryEntry.Code, d.opts.RegistryEntry.Daemon); err != nil {
|
||||
errs = append(errs, core.E("daemon.stop", "registry", err))
|
||||
}
|
||||
}
|
||||
|
||||
d.running = false
|
||||
|
|
|
|||
11
health.go
11
health.go
|
|
@ -104,10 +104,17 @@ func (h *HealthServer) Start() error {
|
|||
|
||||
// Stop gracefully shuts down the health server.
|
||||
func (h *HealthServer) Stop(ctx context.Context) error {
|
||||
if h.server == nil {
|
||||
h.mu.Lock()
|
||||
server := h.server
|
||||
h.server = nil
|
||||
h.listener = nil
|
||||
h.mu.Unlock()
|
||||
|
||||
if server == nil {
|
||||
return nil
|
||||
}
|
||||
return h.server.Shutdown(ctx)
|
||||
|
||||
return server.Shutdown(ctx)
|
||||
}
|
||||
|
||||
// Addr returns the actual address the server is listening on.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue