mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 21:49:22 +00:00
Handle panic in indexer initialisation better (#10534)
* Handle panic in indexer initialisation better * as per @guillep2k
This commit is contained in:
parent
154b137b6d
commit
c32f3da33c
|
@ -64,6 +64,17 @@ func Init() {
|
|||
go func() {
|
||||
start := time.Now()
|
||||
log.Info("PID: %d Initializing Repository Indexer at: %s", os.Getpid(), setting.Indexer.RepoPath)
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Error("PANIC whilst initializing repository indexer: %v\nStacktrace: %s", err, log.Stack(2))
|
||||
log.Error("The indexer files are likely corrupted and may need to be deleted")
|
||||
log.Error("You can completely remove the \"%s\" directory to make Gitea recreate the indexes", setting.Indexer.RepoPath)
|
||||
cancel()
|
||||
indexer.Close()
|
||||
close(waitChannel)
|
||||
log.Fatal("PID: %d Unable to initialize the Repository Indexer at path: %s Error: %v", os.Getpid(), setting.Indexer.RepoPath, err)
|
||||
}
|
||||
}()
|
||||
bleveIndexer, created, err := NewBleveIndexer(setting.Indexer.RepoPath)
|
||||
if err != nil {
|
||||
if bleveIndexer != nil {
|
||||
|
|
|
@ -143,6 +143,14 @@ func InitIssueIndexer(syncReindex bool) {
|
|||
var populate bool
|
||||
switch setting.Indexer.IssueType {
|
||||
case "bleve":
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Error("PANIC whilst initializing issue indexer: %v\nStacktrace: %s", err, log.Stack(2))
|
||||
log.Error("The indexer files are likely corrupted and may need to be deleted")
|
||||
holder.cancel()
|
||||
log.Fatal("PID: %d Unable to initialize the Bleve Issue Indexer at path: %s Error: %v", os.Getpid(), setting.Indexer.IssuePath, err)
|
||||
}
|
||||
}()
|
||||
issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
|
||||
exist, err := issueIndexer.Init()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue