diff options
author | Valery Piashchynski <[email protected]> | 2021-04-19 16:42:28 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-04-19 16:42:28 +0300 |
commit | baa12b092578d41218585d918fb7e1425700272d (patch) | |
tree | 91881bd0ac32c609ea01fafe3bbc15a13a67c392 /plugins/service/plugin.go | |
parent | 112b7b60bbc045f4935e1766be9d2266abf68b31 (diff) |
- Add tests, update Informer implementation
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/service/plugin.go')
-rw-r--r-- | plugins/service/plugin.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/service/plugin.go b/plugins/service/plugin.go index 60ed46c3..91e47e86 100644 --- a/plugins/service/plugin.go +++ b/plugins/service/plugin.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/spiral/errors" + "github.com/spiral/roadrunner/v2/pkg/process" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" ) @@ -54,9 +55,9 @@ func (service *Plugin) Serve() chan error { for i := 0; i < service.cfg.Services[k].ProcessNum; i++ { // create processor structure, which will process all the services service.processes = append(service.processes, NewServiceProcess( - service.cfg.Services[k].RestartAfterExit, + service.cfg.Services[k].RemainAfterExit, service.cfg.Services[k].ExecTimeout, - service.cfg.Services[k].RestartDelay, + service.cfg.Services[k].RestartSec, service.cfg.Services[k].Command, service.logger, errCh, @@ -64,6 +65,7 @@ func (service *Plugin) Serve() chan error { } } + // start all processes for i := 0; i < len(service.processes); i++ { service.processes[i].start() } @@ -72,6 +74,20 @@ func (service *Plugin) Serve() chan error { return errCh } +func (service *Plugin) Workers() []process.State { + service.Lock() + defer service.Unlock() + states := make([]process.State, 0, len(service.processes)) + for i := 0; i < len(service.processes); i++ { + st, err := process.GeneralProcessState(service.processes[i].Pid) + if err != nil { + continue + } + states = append(states, st) + } + return states +} + func (service *Plugin) Stop() error { service.Lock() defer service.Unlock() |