run crawlers with the webapp

This commit is contained in:
2025-01-12 03:35:19 +01:00
parent 3e808899c1
commit 48d8b99fc3
6 changed files with 127 additions and 89 deletions

View File

@@ -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)