Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Add support for scheduled plugins #15

Closed
mariusandra opened this issue Nov 18, 2020 · 3 comments
Closed

Add support for scheduled plugins #15

mariusandra opened this issue Nov 18, 2020 · 3 comments
Assignees

Comments

@mariusandra
Copy link
Collaborator

Todo:

  • Make it possible to register "tasks" in plugins, which can be called through celery (and/or via HTTP in the future?)
  • Add node-redlock and use it to to acquire a "scheduler" lock from redis in just one worker/thread
  • Calculate the "next run at" time for all scheduled tasks per plugin_config and store that somewhere (redis? postgres?)
  • Periodically check if any task needs to run. If so, run it by dispatching a task on celery and then calculating the next run time.
  • Handle rolling updates to plugins - reloading plugins shouldn't reset the scheduled times
  • Tasks scheduled to run while the server was down should be run up after it starts (perhaps except if the "next run at" is less than "time since it should have run"?)
@mariusandra mariusandra self-assigned this Nov 18, 2020
@mariusandra
Copy link
Collaborator Author

We have scheduled plugins live with 0.5.0 of the plugin server via #63

Still to do:

  • Currently there are no guarantees if and when your plugins run. For example making a runEveryHour plugin will mostly run once per hour, but sometimes twice and sometimes not at all. This could be fine though.
  • If you have two instances of plugin server running, the scheduled task will run on both of them. We should use a lock by node-redlock to limit this.
  • You can only schedule tasks that run every minute, hour or day. No custom schedules. Do we need them now?

@Twixes
Copy link
Member

Twixes commented Dec 11, 2020

It'd be really cool if we could do arbitrary schedules, especially since we already schedule them cron-like with scheduleJob, though we'd have to bundle them in a more robust way then.

@mariusandra
Copy link
Collaborator Author

This and https://github.com/PostHog/plugin-server/issues/68 are basically duplicates now. The only thing not done here is arbitrary schedules, and that's kind of what #68 refers to. So in the interest of keeping just one issue, this one goes in the can.

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

No branches or pull requests

2 participants