Skip to content

Commit

Permalink
live: do the automatic check for new submissions every second
Browse files Browse the repository at this point in the history
This should solve a potential hang condition from when the live
server is being worked upon and jobs are being queued
  • Loading branch information
justinclift committed Jun 2, 2024
1 parent 2c2e140 commit 35f2b00
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions live/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"log"
"os"
"time"

com "github.com/sqlitebrowser/dbhub.io/common"
"github.com/sqlitebrowser/dbhub.io/common/config"
Expand Down Expand Up @@ -66,18 +67,18 @@ func main() {
go com.JobQueueListen()

// Launch goroutine event generator for checking submitted jobs
// TODO: This seems to work fine, but is kind of a pita to have enabled while developing this code atm. So we disable it for now.
// NOTE: This seems to work fine, but is kind of a pita to have enabled while developing this code atm. So we disable it for now.
// TODO: Instead of this, should we run some code on startup of the live nodes that checks the database for
// (recent) unhandled requests, and automatically generates a JobQueueCheck() event if some are found?
//go func() {
// for {
// // Tell the JobQueueCheck() goroutine to check for newly submitted jobs
// com.CheckJobQueue <- struct{}{}
//
// // Wait a second before the next check
// time.Sleep(1 * time.Second)
// }
//}()
go func() {
for {
// Tell the JobQueueCheck() goroutine to check for newly submitted jobs
com.CheckJobQueue <- struct{}{}

// Wait a second before the next check
time.Sleep(1 * time.Second)
}
}()

log.Printf("%s: listening for requests", config.Conf.Live.Nodename)

Expand Down

0 comments on commit 35f2b00

Please sign in to comment.