From e005d7f96c1e6db638f6508c0a824e5b8bc9c59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neven=20Jacmenovi=C4=87?= Date: Fri, 9 Jun 2017 23:02:44 +0200 Subject: delayed search index initialization so search can work with addons --- cmd/ponzu/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index 7572dcc..c102aa4 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -137,6 +137,8 @@ var serveCmd = &cobra.Command{ } } + go db.InitSearchIndex() + // save the https port the system is listening on err := db.PutConfig("https_port", fmt.Sprintf("%d", httpsport)) if err != nil { -- cgit v1.2.3 From 8e7e9dab59a951b6d129f48f18f4d14f12b0ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neven=20Jacmenovi=C4=87?= Date: Fri, 9 Jun 2017 23:03:20 +0200 Subject: delayed search index initialization so search can work with addons --- system/db/init.go | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/system/db/init.go b/system/db/init.go index a401a2a..65d3b74 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -85,17 +85,38 @@ func Init() { log.Fatalln("Failed to invalidate cache.", err) } - go func() { - for t := range item.Types { - err := search.MapIndex(t) - if err != nil { - log.Fatalln(err) - return - } +} - SortContent(t) +// InitSearchIndex initializes Search Index for search to be functional +// This was moved out of db.Init and put to main(), because addoon checker was initializing db together with +// search indexing initialisation in time when there were no item.Types defined so search index was always empty when using addons. +// We still have no guarentee whatsoever that item.Types is defined +// Should be called from a goroutine after SetContent is successful (SortContent requirement) +func InitSearchIndex() { + log.Println("init db gofunc START ..............................................................................") + + // if len(item.Types) == 0 { + // log.Println("item.types = 0") + // time.Sleep(time.Second * 1) + // } + + log.Printf("item.Types: %#v", item.Types) + + for t := range item.Types { + err := search.MapIndex(t) + log.Printf("item.Types in gofunc: %#v", t) + log.Printf("err: %#v", err) + if err != nil { + log.Fatalln(err) + return } - }() + + SortContent(t) + + } + + log.Println("init db gofunc END ..............................................................................") + } // SystemInitComplete checks if there is at least 1 admin user in the db which -- cgit v1.2.3 From 660cac0f7b4a6d731d07ac4f9ac6489f351eb09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neven=20Jacmenovi=C4=87?= Date: Fri, 9 Jun 2017 23:17:44 +0200 Subject: delayed search index initialization so search can work with addons --- system/db/init.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/system/db/init.go b/system/db/init.go index 65d3b74..8bd5cad 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -93,30 +93,14 @@ func Init() { // We still have no guarentee whatsoever that item.Types is defined // Should be called from a goroutine after SetContent is successful (SortContent requirement) func InitSearchIndex() { - log.Println("init db gofunc START ..............................................................................") - - // if len(item.Types) == 0 { - // log.Println("item.types = 0") - // time.Sleep(time.Second * 1) - // } - - log.Printf("item.Types: %#v", item.Types) - for t := range item.Types { err := search.MapIndex(t) - log.Printf("item.Types in gofunc: %#v", t) - log.Printf("err: %#v", err) if err != nil { log.Fatalln(err) return } - SortContent(t) - } - - log.Println("init db gofunc END ..............................................................................") - } // SystemInitComplete checks if there is at least 1 admin user in the db which -- cgit v1.2.3 From ea998eb195063617aa485ce99b0e5bd1697ecab5 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 10 Jun 2017 15:43:35 -0700 Subject: small typo in comments --- system/db/init.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/db/init.go b/system/db/init.go index 8bd5cad..ad0011f 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -88,9 +88,9 @@ func Init() { } // InitSearchIndex initializes Search Index for search to be functional -// This was moved out of db.Init and put to main(), because addoon checker was initializing db together with -// search indexing initialisation in time when there were no item.Types defined so search index was always empty when using addons. -// We still have no guarentee whatsoever that item.Types is defined +// This was moved out of db.Init and put to main(), because addon checker was initializing db together with +// search indexing initialisation in time when there were no item.Types defined so search index was always +// empty when using addons. We still have no guarentee whatsoever that item.Types is defined // Should be called from a goroutine after SetContent is successful (SortContent requirement) func InitSearchIndex() { for t := range item.Types { -- cgit v1.2.3