diff options
author | Valery Piashchynski <[email protected]> | 2021-02-04 12:26:16 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-04 12:26:16 +0300 |
commit | b9c9909b98c1b3e15421a4bcad9e8fcc01332d37 (patch) | |
tree | b969808a6bdd67bbb566421a2158a51c9de3713e /plugins/server/plugin.go | |
parent | 8a8d9d7c64226397792e8f1aa7cc607ab413906e (diff) | |
parent | a902a06e670d70b0f806899765bdb206977e7698 (diff) |
Merge pull request #526 from spiral/fix/memory_leaksv2.0.0-beta.24
bug(leak): workers memory leak
Diffstat (limited to 'plugins/server/plugin.go')
-rw-r--r-- | plugins/server/plugin.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go index 73ce71f7..99d93d19 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: @@ -234,9 +234,12 @@ func (server *Plugin) collectPoolLogs(event interface{}) { if we, ok := event.(events.WorkerEvent); ok { switch we.Event { case events.EventWorkerError: - server.log.Error(we.Payload.(error).Error(), "pid", we.Worker.(worker.BaseProcess).Pid()) + server.log.Error(strings.TrimRight(we.Payload.(error).Error(), " \n\t")) case events.EventWorkerLog: - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t"), "pid", we.Worker.(worker.BaseProcess).Pid()) + server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + case events.EventWorkerStderr: + // TODO unsafe byte to string convert + server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) } } } @@ -245,9 +248,12 @@ func (server *Plugin) collectWorkerLogs(event interface{}) { if we, ok := event.(events.WorkerEvent); ok { switch we.Event { case events.EventWorkerError: - server.log.Error(we.Payload.(error).Error(), "pid", we.Worker.(worker.BaseProcess).Pid()) + server.log.Error(strings.TrimRight(we.Payload.(error).Error(), " \n\t")) case events.EventWorkerLog: - server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t"), "pid", we.Worker.(worker.BaseProcess).Pid()) + server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) + case events.EventWorkerStderr: + // TODO unsafe byte to string convert + server.log.Debug(strings.TrimRight(string(we.Payload.([]byte)), " \n\t")) } } } |