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

Question : Cancel Periodic tasks? #812

Open
rnbokade opened this issue Jul 18, 2024 · 1 comment
Open

Question : Cancel Periodic tasks? #812

rnbokade opened this issue Jul 18, 2024 · 1 comment

Comments

@rnbokade
Copy link

I am building a sensor management system, where in I want to be able to add periodic tasks for polling sensors at specific intervals. however, the web interface would also allow, the user to tweak the polling interval of particular sensor as such. So I want to be able to remove the scheduled job and schedule a new one. How to do this?

@xiaoz194
Copy link

xiaoz194 commented Sep 19, 2024

hello, I also have some problem about regist periodic tasks,could u please help me?

my code like this, my normal task is ok, but periodic task is failure, error msg is : "checkAllJobs" Task not registered with this worker.

I don't know which step is wrong.

{
        // .....

	// regist tasks
	tasksMap := initAsyncTaskMap()
	err = server.RegisterTasks(tasksMap) // ok
	// regist periodic task 
	signature := &tasks.Signature{
		Name: "checkAllJobs",
	}
	if !server.IsTaskRegistered("checkAllJobs") {
		logutil.G(ctx).Infof("checkAllJobs task not regist")
		err = server.RegisterPeriodicTask("1 * * * ?", "checkAllJobs", signature)       // failed err: task not register
	}
	return server, err
}


func initAsyncTaskMap() map[string]interface{} {
	tasksMap := map[string]interface{}{
		"produce":      task.Produce,                      // this is normal task, and everything is ok
		"checkAllJobs": task.CheckAllJobs,      // this is periodic tasks
	}
	return tasksMap
}

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

No branches or pull requests

2 participants