diff options
author | Valery Piashchynski <[email protected]> | 2021-02-03 17:31:17 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-02-03 17:31:17 +0300 |
commit | 8eda5dc6f0f7e05d7b3d62e1861af05b49a2574a (patch) | |
tree | fae66ad49d2a4624a7caf45a5bf07d53e5c7d26f /plugins/server/plugin.go | |
parent | 20a1a5d2eb26090e0eef0e6772330ee2a52526fa (diff) |
Fix memory leak in the Worker.go
Diffstat (limited to 'plugins/server/plugin.go')
-rw-r--r-- | plugins/server/plugin.go | 10 |
1 files changed, 8 insertions, 2 deletions
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))) } } } |