Stop plugin healthchecks before shutting down plugins (#11972)
* cancel plugin check when shutdown * move to top * stop healthcheck job only once, and if started * whitespace
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
2980d341d4
Коммит
9e9f1bb2aa
@@ -284,6 +284,10 @@ func (env *Environment) RestartPlugin(id string) error {
|
|||||||
|
|
||||||
// Shutdown deactivates all plugins and gracefully shuts down the environment.
|
// Shutdown deactivates all plugins and gracefully shuts down the environment.
|
||||||
func (env *Environment) Shutdown() {
|
func (env *Environment) Shutdown() {
|
||||||
|
if env.pluginHealthCheckJob != nil {
|
||||||
|
env.pluginHealthCheckJob.Cancel()
|
||||||
|
}
|
||||||
|
|
||||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||||
rp := value.(*registeredPlugin)
|
rp := value.(*registeredPlugin)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/mlog"
|
"github.com/mattermost/mattermost-server/mlog"
|
||||||
@@ -19,9 +20,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type PluginHealthCheckJob struct {
|
type PluginHealthCheckJob struct {
|
||||||
cancel chan struct{}
|
cancel chan struct{}
|
||||||
cancelled chan struct{}
|
cancelled chan struct{}
|
||||||
env *Environment
|
cancelOnce sync.Once
|
||||||
|
env *Environment
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitPluginHealthCheckJob starts a new job if one is not running and is set to enabled, or kills an existing one if set to disabled.
|
// InitPluginHealthCheckJob starts a new job if one is not running and is set to enabled, or kills an existing one if set to disabled.
|
||||||
@@ -125,7 +127,9 @@ func newPluginHealthCheckJob(env *Environment) *PluginHealthCheckJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (job *PluginHealthCheckJob) Cancel() {
|
func (job *PluginHealthCheckJob) Cancel() {
|
||||||
close(job.cancel)
|
job.cancelOnce.Do(func() {
|
||||||
|
close(job.cancel)
|
||||||
|
})
|
||||||
<-job.cancelled
|
<-job.cancelled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user