MM-22235: Fixing stop/start behavior on Elasticsearch engine (#13887)

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-03-03 17:52:59 +01:00
коммит произвёл GitHub
родитель 058f235050
Коммит ccc57e56c3
4 изменённых файлов: 17 добавлений и 12 удалений

Просмотреть файл

@@ -82,7 +82,7 @@ type Server struct {
licenseValue atomic.Value
clientLicenseValue atomic.Value
licenseListeners map[string]func()
licenseListeners map[string]func(*model.License, *model.License)
timezones *timezones.Timezones
@@ -143,7 +143,7 @@ func NewServer(options ...Option) (*Server, error) {
s := &Server{
goroutineExitSignal: make(chan struct{}, 1),
RootRouter: rootRouter,
licenseListeners: map[string]func(){},
licenseListeners: map[string]func(*model.License, *model.License){},
clientConfig: make(map[string]string),
}
@@ -776,14 +776,14 @@ func (s *Server) StartElasticsearch() {
}
})
s.AddLicenseListener(func() {
if s.License() != nil {
s.AddLicenseListener(func(oldLicense, newLicense *model.License) {
if oldLicense == nil && newLicense != nil {
s.Go(func() {
if err := s.Elasticsearch.Start(); err != nil {
mlog.Error(err.Error())
}
})
} else {
} else if oldLicense != nil && newLicense == nil {
s.Go(func() {
if err := s.Elasticsearch.Stop(); err != nil {
mlog.Error(err.Error())