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

Support a 'singleton' job? #13

Closed
jsmestad opened this issue Feb 23, 2017 · 2 comments
Closed

Support a 'singleton' job? #13

jsmestad opened this issue Feb 23, 2017 · 2 comments

Comments

@jsmestad
Copy link
Contributor

We have a nightly task that sometimes takes a bit to run. How difficult would it be to support a "singleton" CRON task? I know the matthuhiggins/sidekiq-cron project supports this, but we use sidecloq for a few different types of jobs.

I'd be happy to jump in and do the work if you have some advice on how to approach the implementation (or if you think its a bad idea).

@mattyr
Copy link
Owner

mattyr commented Feb 23, 2017

do you mean a task that you don't want potentially overlapping itself? iow, a job that is scheduled each hour might take more than an hour to run, and if it is running, don't reschedule it?

if so, i've been torn conceptually about where the responsibility lies. CRON (as in linux CRON) itself doesn't provide this sort of feature right? i've had situations in the past like this, and i've left it up to the job to determine if it's stepping on itself. it's easy enough to grab a db or redis lock.

i'm tempted to stick with the unix philosophy and keep this tools as small and singularly focused as
possible, but i'm not totally against looking at some code.

i'd suggest implementing it as an in-job feature, and maybe post the code snippet here that you think is generic enough to be applied. basically, have logic in the job that says, "nope, i'm already running". i feel like that could spark some discussion, and we can see if it's worth integrating. (plus doesn't have you wasting time on PR that ends up being not included).

@mattyr
Copy link
Owner

mattyr commented Mar 9, 2017

closing for now, feel free to reopen if you want to continue discussion.

@mattyr mattyr closed this as completed Mar 9, 2017
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