Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
This commit is contained in:
parent
1cd6233cef
commit
5cdfde2ebf
1 changed files with 15 additions and 17 deletions
|
@ -143,25 +143,23 @@ func InitIssueIndexer(syncReindex bool) {
|
||||||
var populate bool
|
var populate bool
|
||||||
switch setting.Indexer.IssueType {
|
switch setting.Indexer.IssueType {
|
||||||
case "bleve":
|
case "bleve":
|
||||||
graceful.GetManager().RunWithShutdownFns(func(_, atTerminate func(context.Context, func())) {
|
issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
|
||||||
issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
|
exist, err := issueIndexer.Init()
|
||||||
exist, err := issueIndexer.Init()
|
if err != nil {
|
||||||
if err != nil {
|
holder.cancel()
|
||||||
holder.cancel()
|
log.Fatal("Unable to initialize Bleve Issue Indexer: %v", err)
|
||||||
log.Fatal("Unable to initialize Bleve Issue Indexer: %v", err)
|
}
|
||||||
|
populate = !exist
|
||||||
|
holder.set(issueIndexer)
|
||||||
|
graceful.GetManager().RunAtTerminate(context.Background(), func() {
|
||||||
|
log.Debug("Closing issue indexer")
|
||||||
|
issueIndexer := holder.get()
|
||||||
|
if issueIndexer != nil {
|
||||||
|
issueIndexer.Close()
|
||||||
}
|
}
|
||||||
populate = !exist
|
log.Info("PID: %d Issue Indexer closed", os.Getpid())
|
||||||
holder.set(issueIndexer)
|
|
||||||
atTerminate(context.Background(), func() {
|
|
||||||
log.Debug("Closing issue indexer")
|
|
||||||
issueIndexer := holder.get()
|
|
||||||
if issueIndexer != nil {
|
|
||||||
issueIndexer.Close()
|
|
||||||
}
|
|
||||||
log.Info("PID: %d Issue Indexer closed", os.Getpid())
|
|
||||||
})
|
|
||||||
log.Debug("Created Bleve Indexer")
|
|
||||||
})
|
})
|
||||||
|
log.Debug("Created Bleve Indexer")
|
||||||
case "db":
|
case "db":
|
||||||
issueIndexer := &DBIndexer{}
|
issueIndexer := &DBIndexer{}
|
||||||
holder.set(issueIndexer)
|
holder.set(issueIndexer)
|
||||||
|
|
Reference in a new issue