mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-28 12:16:48 +08:00
42 lines
666 B
Go
42 lines
666 B
Go
package plg_search_sqlitefts
|
|
|
|
import (
|
|
"time"
|
|
|
|
. "github.com/mickael-kerjean/filestash/server/common"
|
|
)
|
|
|
|
var onConfigChange ChangeListener
|
|
|
|
func init() {
|
|
onConfigChange = Config.ListenForChange()
|
|
Hooks.Register.Onload(func() {
|
|
for i := 0; i < SEARCH_PROCESS_PAR(); i++ {
|
|
go runner()
|
|
}
|
|
})
|
|
}
|
|
|
|
func runner() {
|
|
startSearch := false
|
|
for {
|
|
if SEARCH_ENABLE() == false {
|
|
select {
|
|
case <-onConfigChange.Listener:
|
|
startSearch = SEARCH_ENABLE()
|
|
}
|
|
if startSearch == false {
|
|
continue
|
|
}
|
|
}
|
|
crwlr := NextCrawler()
|
|
if crwlr == nil {
|
|
time.Sleep(5 * time.Second)
|
|
continue
|
|
}
|
|
crwlr.mu.Lock()
|
|
crwlr.Run()
|
|
crwlr.mu.Unlock()
|
|
}
|
|
}
|