Closed noloman closed 6 months ago
Describe the bug I'm trying to schedule a task to be run every 5 minutes for testing purposes and nothing is happening.
To Reproduce
func scheduleBackgroundJobs(app *application) { netherlands, err := time.LoadLocation("Europe/Amsterdam") if err != nil { app.logger.Error("could not load location: %v", err) } redisConnOpt := asynq.RedisClientOpt{Addr: app.config.redisAddr, Password: "mytestpass"} scheduler := asynq.NewScheduler(redisConnOpt, &asynq.SchedulerOpts{ Location: netherlands, }) client := asynq.NewClient(redisConnOpt) defer client.Close() jobsUpdateTask, err := app.jobsUpdateTask.NewJobsUpdateTask() if err != nil { app.logger.Error("could not create task: %v", err) } entryID, err := scheduler.Register("*/5 * * * *", jobsUpdateTask) if err != nil { app.logger.Error("Error scheduling task: %v", err) } app.logger.Info("registered an entry: %q\n", entryID) if err := scheduler.Run(); err != nil { app.logger.Error("Error running scheduler: %v", err) } }
However I see nothing being scheduled in the console (while before, I used client.enqueue and it worked). Running asynq dash -p shows the scheduled tasks in pending:
client.enqueue
asynq dash -p
You need to run the Server alongside the Scheduler as described in the wiki. The server provisions workers.
Server
Scheduler
Describe the bug I'm trying to schedule a task to be run every 5 minutes for testing purposes and nothing is happening.
To Reproduce
However I see nothing being scheduled in the console (while before, I used
client.enqueue
and it worked). Runningasynq dash -p
shows the scheduled tasks in pending: