bamzi / jobrunner

Framework for performing work asynchronously, outside of the request flow
MIT License
1.04k stars 99 forks source link

Proposal: Save state on exit #3

Closed alehano closed 8 years ago

alehano commented 8 years ago

It would be great if package optionally save state (as a .gob or .json files for example) on os interrupt signals. And restore it when run again. You can set path to save state files as a third parameter in .Start(). If it set, saving will be active.

bamzi commented 8 years ago

@alehano I think I understand what you're asking. I guess one case would be, if cron job is in mid process, then there's an interruption that kills the app, ability to either pick up where things were left off or restart from the last incomplete cron job. Right?

One solution may be to take a snapshot of the cron job before processing it, in which the snapshot will expire if the job is executed successfully. This way if interruption happens, and there's an existing outstanding job (snapshot), execute it first before starting a new job.

The more I think about this, the more i feel it's on a case by case basis where each development team would want to do it in their own way. On the app level, it's simple to implement a custom process to handle these type of cases. One the package level, though, I'm not sold it's necessary.

alehano commented 8 years ago

Yeah, may be you right.

roideuniverse commented 8 years ago

:+1: