-
Notifications
You must be signed in to change notification settings - Fork 110
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
Can I use synced-cron to time a single server event? #41
Comments
I've reearched a bit deeper. It seems that SyncedCron.add({
name: cron_name,
schedule: function (parser) {
// ending_at is a Date object set to some future date
// there is no recurrence
return parser.recur().on(ending_at).fullDate();
},
job: function () {
console.log("hep!");
// remove job so it doesn't recur
SyncedCron.remove(cron_name);
}
}); The above code results in the following exception:
... since in the meteor-synced-cron/synced-cron-server.js Line 240 in 125ae97
Other ways to make this work? Would be easy to patch |
So, I created a patch... What it does is simply removing the job if the schedule doesn't have any more events. Also a minor improvement: If the entry is removed inside its job function body, the next event isn't triggered. (The |
My apologies, I am now experiencing what everyone else on this thread is seeing. For some reason this method worked until I restarted my server. The meteor daemon is now crashing with my jobs scheduled in this way.. |
Thanks for the input @tylerstraub . My plan is still to take a look at this ticket as soon as I have some free time. |
Don't know how much the code has developed, but my pull request solving this problem is quite simple – you could just use that ;) I'm using it in production, anyways. |
@dalgard - The reason we ask that PR authors write tests is because we maintain quite a few o/s projects and don't necessarily have the bandwidth to go through each PR in detail and support it into the future. It's actually not that we're in doubt whether the code is production ready (we give you guys the benefit of doubt). If the PR comes with tests however, we're comfortable merging it with less scrutiny knowing that the author has described exactly what the functionality does and in fact we won't break it in future versions. This way we can support functionality that we don't actually use ourselves as the tests become the vehicle that ensures we don't break stuff that others rely on. In short, if we don't use something ourselves and there are no tests for it there is a pretty good chance that functionality may break in between releases - this is something we obviously want to avoid. Hence with PR's like yours that don't come with tests, we need to schedule in the time and come up to speed with the functionality + write tests ourselves. Unfortunately, during busy times this falls down our priority queue. |
I totally understand and earnestly consider it a healthy priority – had it been my project, I hope I would be equally methodical. All I would do, is encourage you to review my PR and see how limited the adjustments would be for resolving this issue. Throwing together a patch on the basis of the lines I've submitted is a convenient path when professional obligations and other things take rightful precedence. |
Any update on this? Just noticed this issue on my project. It actually causes my server to crash and restart. In the meantime I'll see about adopting the solution that @dalgard came up with. |
FYI there's an orphaned package which uses dalgard's solution. I've been using it... so far so good, but if a solution is settled on in the official package I'll be happy to switch back. |
+1 for merge. |
+1 for merge |
+1 for tests to be added + merge |
+1 for merge. |
+1 as well! |
Released a fix to point in time schedules in version 1.3.0. Let me know if there are any issues with it. Thanks for your patience. |
I am using version 1.3.2, and want to fire a once-off job, but still facing the same issue:
Console prints:
|
@yyl The cron is working as it should, the on method just requires a date not a timestamp.
|
@adrianbadarau great that works, thanks! |
…ed-cron * 'master' of https://github.com/jamesgibson14/meteor-synced-cron: Adjusted versions Prevent _ensureIndex call from crashing an app Adjusted versions Fix E11000 duplicate key error collection Fixed rescheduling jobs when mongodb timed out during execution of job. Add comma so users can copy-paste without fixing syntax error Access to job name when running the actual job Update README.md Release version 1.3.2 with dependency on Meteor 1.3 Bump to version 1.3.1 Remove the symlink in the example folder to prevent the symlink cycle error when building for Meteor 1.3 Version 1.3.0 Adds patch to later snippet to not throw on point in time schedules for percolatestudio#41 Version bump Discard milliseconds from intendedAt One time scheduled events don't have a next occurrence - handle those gracefully small typo Added quotes to logged line when entry is removed. # Conflicts: # .npm/package/npm-shrinkwrap.json # README.md # example/.meteor/.finished-upgraders # example/.meteor/release # example/.meteor/versions # package.js
I'm building an auction system where the bidding on each item ends at a specific time. When an auction ends, certain operations should be executed. This is a one-time event, of course.
SyncedCron seems like the most robust solution for timed server events – is there an easy way of creating a job that runs once at a specific time in the future?
Thanks!
The text was updated successfully, but these errors were encountered: