Skip to content

Commit

Permalink
Add flag to skip checking existing jobs to server mode
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Jul 12, 2024
1 parent b493578 commit 37e97ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ var defaultFileContent = []byte(`{
},
*/
// should CORS headers be set to allow requests from anywhere
"cors" : true
"cors" : true,
// should old jobs be checked on startup
"checkold" : true
},
"worker": {
// should workers exit immediately after SIGINT/SIGTERM signal or gracefully wait for job completion
Expand Down Expand Up @@ -224,6 +226,7 @@ type ConfigServer struct {
PathPrefix string `json:"pathprefix"`
DbManagment bool `json:"dbmanagment"`
CORS bool `json:"cors"`
CheckOld bool `json:"checkold"`
Auth *ConfigAuth `json:"auth"`
RateLimit *ConfigRateLimit `json:"ratelimit"`
}
Expand Down
4 changes: 2 additions & 2 deletions backend/jobsystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type RedisJobSystem struct {
Client *redis.Client
}

func MakeRedisJobSystem(config ConfigRedis, results string, isServer bool) (*RedisJobSystem, error) {
func MakeRedisJobSystem(config ConfigRedis, results string, checkOld bool) (*RedisJobSystem, error) {
jobsystem := &RedisJobSystem{
BaseJobSystem{},
redis.NewClient(&redis.Options{
Expand All @@ -199,7 +199,7 @@ func MakeRedisJobSystem(config ConfigRedis, results string, isServer bool) (*Red
jobsystem.StatusMutex = &sync.Mutex{}
jobsystem.Results = results

if !isServer {
if !checkOld {
return jobsystem, nil
}

Expand Down
2 changes: 1 addition & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {
}
worker(jobsystem, config)
case SERVER:
jobsystem, err := MakeRedisJobSystem(config.Redis, config.Paths.Results, true)
jobsystem, err := MakeRedisJobSystem(config.Redis, config.Paths.Results, config.Server.CheckOld)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 37e97ba

Please sign in to comment.