run crawlers with the webapp
This commit is contained in:
@@ -2,10 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"crowsnest/internal/app"
|
||||
"crowsnest/internal/crawler"
|
||||
"crowsnest/internal/middleware"
|
||||
"crowsnest/internal/model/database"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
@@ -16,6 +18,18 @@ func main() {
|
||||
log.Fatal("failed to connect to database due to", err.Error())
|
||||
}
|
||||
|
||||
// run web crawlers
|
||||
coll := crawler.Crawler{
|
||||
Articles: &database.ArticleModel{DB: db},
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
coll.ZeitCollectIndex()
|
||||
coll.SpiegelCollectIndex()
|
||||
time.Sleep(5 * time.Minute)
|
||||
}
|
||||
}()
|
||||
|
||||
// define app
|
||||
webapp := app.NewApp(db)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user