aboutsummaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
Diffstat (limited to 'controller')
-rw-r--r--controller/controller.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/controller/controller.go b/controller/controller.go
index 7fc8748..e381bf8 100644
--- a/controller/controller.go
+++ b/controller/controller.go
@@ -2,6 +2,7 @@ package controller
import (
"net/http"
+ "time"
"git.sr.ht/~gabrielgio/midr/db"
"git.sr.ht/~gabrielgio/midr/worker"
@@ -13,7 +14,7 @@ type Env struct {
Worker worker.Worker
}
-func (e Env) GetEntries(c *gin.Context) {
+func (e *Env) GetEntries(c *gin.Context) {
entries := e.Entries.All()
c.HTML(http.StatusOK, "index", entries)
}
@@ -54,3 +55,17 @@ func (e *Env) GetJobs(c *gin.Context) {
jobs := e.Worker.GetJobs()
c.JSON(http.StatusOK, jobs)
}
+
+func (e *Env) StartScheduler() {
+ e.Worker.StartReader()
+ go func() {
+ for true {
+ entries := e.Entries.All()
+
+ for _, entry := range entries {
+ e.Worker.SpawnWorker(entry.ID, entry.Link, entry.OutputFolder)
+ }
+ time.Sleep(30 * time.Minute)
+ }
+ }()
+}