summaryrefslogtreecommitdiffstats
path: root/modules/indexer
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-11 23:21:20 +0000
committerGitHub <noreply@github.com>2020-02-12 00:21:20 +0100
commit1125d1453bdbc2aa51862b94d7c8ec4c149284fc (patch)
tree00e81f3baf399013939852d315105f3406af3761 /modules/indexer
parent6c823c75601662359a1939e6d39058aa46fc73a5 (diff)
downloadgitea-1125d1453bdbc2aa51862b94d7c8ec4c149284fc.tar.gz
gitea-1125d1453bdbc2aa51862b94d7c8ec4c149284fc.zip
Stop hanging issue indexer initialisation from preventing shutdown (#10243)
Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Diffstat (limited to 'modules/indexer')
-rw-r--r--modules/indexer/issues/indexer.go32
1 files changed, 15 insertions, 17 deletions
diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go
index 95bd5b8a63..c942013e34 100644
--- a/modules/indexer/issues/indexer.go
+++ b/modules/indexer/issues/indexer.go
@@ -143,25 +143,23 @@ func InitIssueIndexer(syncReindex bool) {
var populate bool
switch setting.Indexer.IssueType {
case "bleve":
- graceful.GetManager().RunWithShutdownFns(func(_, atTerminate func(context.Context, func())) {
- issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
- exist, err := issueIndexer.Init()
- if err != nil {
- holder.cancel()
- log.Fatal("Unable to initialize Bleve Issue Indexer: %v", err)
+ issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
+ exist, err := issueIndexer.Init()
+ if err != nil {
+ holder.cancel()
+ 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
- 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.Info("PID: %d Issue Indexer closed", os.Getpid())
})
+ log.Debug("Created Bleve Indexer")
case "db":
issueIndexer := &DBIndexer{}
holder.set(issueIndexer)