From 8eda5dc6f0f7e05d7b3d62e1861af05b49a2574a Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Wed, 3 Feb 2021 17:31:17 +0300 Subject: Fix memory leak in the Worker.go --- plugins/informer/rpc.go | 1 - plugins/server/plugin.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/informer/rpc.go b/plugins/informer/rpc.go index c036ae96..55a9832b 100644 --- a/plugins/informer/rpc.go +++ b/plugins/informer/rpc.go @@ -26,7 +26,6 @@ func (rpc *rpc) List(_ bool, list *[]string) error { *list = append(*list, name) } rpc.log.Debug("list of services", "list", *list) - rpc.log.Debug("successfully finished List method") return nil } diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go index 73ce71f7..18a3a316 100644 --- a/plugins/server/plugin.go +++ b/plugins/server/plugin.go @@ -140,7 +140,7 @@ func (server *Plugin) NewWorkerPool(ctx context.Context, opt pool.Config, env En } list := make([]events.Listener, 0, 1) - list = append(list, server.collectPoolLogs) + list = append(list, server.collectEvents) if len(listeners) != 0 { list = append(list, listeners...) } @@ -201,7 +201,7 @@ func (server *Plugin) setEnv(e Env) []string { return env } -func (server *Plugin) collectPoolLogs(event interface{}) { +func (server *Plugin) collectEvents(event interface{}) { if we, ok := event.(events.PoolEvent); ok { switch we.Event { case events.EventMaxMemory: @@ -235,6 +235,9 @@ func (server *Plugin) collectPoolLogs(event interface{}) { switch we.Event { case events.EventWorkerError: server.log.Error(we.Payload.(error).Error(), "pid", we.Worker.(worker.BaseProcess).Pid()) + case events.EventWorkerStderr: + // TODO unsafe byte to string convertation + server.log.Debug("worker stderr", "pid", we.Worker.(worker.BaseProcess).Pid(), "message", string(we.Payload.([]byte))) case events.EventWorkerLog: server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t"), "pid", we.Worker.(worker.BaseProcess).Pid()) } @@ -248,6 +251,9 @@ func (server *Plugin) collectWorkerLogs(event interface{}) { server.log.Error(we.Payload.(error).Error(), "pid", we.Worker.(worker.BaseProcess).Pid()) case events.EventWorkerLog: server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t"), "pid", we.Worker.(worker.BaseProcess).Pid()) + case events.EventWorkerStderr: + // TODO unsafe byte to string convertation + server.log.Debug("worker stderr", "pid", we.Worker.(worker.BaseProcess).Pid(), "message", string(we.Payload.([]byte))) } } } -- cgit v1.2.3