MM-11243: Make Elasticsearch work after enabling without restart. (#9146)
* MM-11243: Make Elasticsearch work after enabling without restart. * Also cope with config vars changing whilst enabled.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8948b91d7a
Коммит
185ed89978
51
app/app.go
51
app/app.go
@@ -680,3 +680,54 @@ func (a *App) DoEmojisPermissionsMigration() {
|
|||||||
mlog.Critical(fmt.Sprint(result.Err))
|
mlog.Critical(fmt.Sprint(result.Err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) StartElasticsearch() {
|
||||||
|
a.Go(func() {
|
||||||
|
if err := a.Elasticsearch.Start(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
a.AddConfigListener(func(oldConfig *model.Config, newConfig *model.Config) {
|
||||||
|
if *oldConfig.ElasticsearchSettings.EnableIndexing == false && *newConfig.ElasticsearchSettings.EnableIndexing == true {
|
||||||
|
a.Go(func() {
|
||||||
|
if err := a.Elasticsearch.Start(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if *oldConfig.ElasticsearchSettings.EnableIndexing == true && *newConfig.ElasticsearchSettings.EnableIndexing == false {
|
||||||
|
a.Go(func() {
|
||||||
|
if err := a.Elasticsearch.Stop(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if *oldConfig.ElasticsearchSettings.Password != *newConfig.ElasticsearchSettings.Password || *oldConfig.ElasticsearchSettings.Username != *newConfig.ElasticsearchSettings.Username || *oldConfig.ElasticsearchSettings.ConnectionUrl != *newConfig.ElasticsearchSettings.ConnectionUrl || *oldConfig.ElasticsearchSettings.Sniff != *newConfig.ElasticsearchSettings.Sniff {
|
||||||
|
a.Go(func() {
|
||||||
|
if *oldConfig.ElasticsearchSettings.EnableIndexing == true {
|
||||||
|
if err := a.Elasticsearch.Stop(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
if err := a.Elasticsearch.Start(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
a.AddLicenseListener(func() {
|
||||||
|
if a.License() != nil {
|
||||||
|
a.Go(func() {
|
||||||
|
if err := a.Elasticsearch.Start(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
a.Go(func() {
|
||||||
|
if err := a.Elasticsearch.Stop(); err != nil {
|
||||||
|
mlog.Error(err.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -176,11 +176,7 @@ func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if a.Elasticsearch != nil {
|
if a.Elasticsearch != nil {
|
||||||
a.Go(func() {
|
a.StartElasticsearch()
|
||||||
if err := a.Elasticsearch.Start(); err != nil {
|
|
||||||
mlog.Error(err.Error())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *a.Config().JobSettings.RunJobs {
|
if *a.Config().JobSettings.RunJobs {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
type ElasticsearchInterface interface {
|
type ElasticsearchInterface interface {
|
||||||
Start() *model.AppError
|
Start() *model.AppError
|
||||||
|
Stop() *model.AppError
|
||||||
IndexPost(post *model.Post, teamId string) *model.AppError
|
IndexPost(post *model.Post, teamId string) *model.AppError
|
||||||
SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams) ([]string, model.PostSearchMatches, *model.AppError)
|
SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams) ([]string, model.PostSearchMatches, *model.AppError)
|
||||||
DeletePost(post *model.Post) *model.AppError
|
DeletePost(post *model.Post) *model.AppError
|
||||||
|
|||||||
@@ -167,6 +167,14 @@
|
|||||||
"id": "api.channel.join_channel.already_deleted.app_error",
|
"id": "api.channel.join_channel.already_deleted.app_error",
|
||||||
"translation": "Channel is already deleted"
|
"translation": "Channel is already deleted"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "ent.elasticsearch.start.already_started.app_error",
|
||||||
|
"translation": "Elasticsearch is already started"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ent.elasticsearch.stop.already_stopped.app_error",
|
||||||
|
"translation": "Elasticsearch is already stopped"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.channel.join_channel.permissions.app_error",
|
"id": "api.channel.join_channel.permissions.app_error",
|
||||||
"translation": "You do not have the appropriate permissions"
|
"translation": "You do not have the appropriate permissions"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user