summaryrefslogtreecommitdiff
path: root/plugins/service/plugin.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/service/plugin.go')
-rw-r--r--plugins/service/plugin.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/service/plugin.go b/plugins/service/plugin.go
index bc72dbaf..60ed46c3 100644
--- a/plugins/service/plugin.go
+++ b/plugins/service/plugin.go
@@ -43,6 +43,10 @@ func (service *Plugin) Serve() chan error {
// start processing
go func() {
+ // lock here, because Stop command might be invoked during the Serve
+ service.Lock()
+ defer service.Unlock()
+
service.processes = make([]*Process, 0, len(service.cfg.Services))
// for the every service
for k := range service.cfg.Services {
@@ -60,11 +64,9 @@ func (service *Plugin) Serve() chan error {
}
}
- service.Lock()
for i := 0; i < len(service.processes); i++ {
service.processes[i].start()
}
- service.Unlock()
}()
return errCh