Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to schedule a task #881

Closed
noloman opened this issue May 5, 2024 · 1 comment
Closed

[BUG] Unable to schedule a task #881

noloman opened this issue May 5, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@noloman
Copy link

noloman commented May 5, 2024

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:

Screenshot 2024-05-05 at 12 42 46 Screenshot 2024-05-05 at 12 43 12
@noloman noloman added the bug Something isn't working label May 5, 2024
@kamikazechaser kamikazechaser added question Further information is requested and removed bug Something isn't working labels May 6, 2024
@kamikazechaser
Copy link
Collaborator

kamikazechaser commented May 6, 2024

You need to run the Server alongside the Scheduler as described in the wiki. The server provisions workers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants