[Koha-devel] Cronjob to run plugin cronjobs?

David Cook dcook at prosentient.com.au
Fri Jun 8 03:18:53 CEST 2018


This kind of thing has been discussed periodically over the years but it never really gets anywhere.

 

I think using cron might be shoehorning things a bit. Cron is great for packaged routine cronjobs and system administration stuff, but for application workloads… I’m not so sure. What about Celery (http://www.celeryproject.org/) or Gearman (http://gearman.org/) or some other job server?

 

For https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10662, I actually wrote my own job server using POE::Component::JobQueue (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html <https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=10662&attachment=71008> &bug=10662&attachment=71008). (Originally, I wrote a generic job/task server for all of Koha but then I figured I was trying to be all things to all people, so I scrapped that idea and just made my OAI-PMH harvester daemon deal with OAI-PMH tasks/jobs. 

 

In my code, I actually have 2 job queues. The 1st queue is actually in the MySQL database, and the daemon polls the database to finds import jobs. It’s not the best solution, but I think I wanted a certain amount of persistence to that queue and to interrogate the data without talking to the job server. The 2nd queue is an in-memory queue. The Koha web user sends a message to the daemon telling it to down from an OAI-PMH server, the job server enqueues the job, and then a predetermined number of workers are forked to do the work of N jobs. 

 

Oh I also made the queue workers pluggable so that it was easy to make workers do whatever. I just made sure they had a run() method that expected certain arguments from the job server. After that, worker plugins were free to do whatever they needed to do. 

 

Anyway, that’s just my 2 cents.  Cron is a tried and true job scheduler for sure… but I don’t think it is the be all and end all. (If you do go with 1 cronjob to rule them all, you’ll need to think about locking, so that long-running cronjobs don’t end up clobbering each other and generally creating havoc. 

 

I was looking for more resources on task queues when I actually found this: “A cron job makes an HTTP GET request to a URL as scheduled. The handler for that URL executes the logic when it is called.” https://cloud.google.com/appengine/docs/standard/python/config/cron. This doesn’t look like a true “cron” job either though. It looks like a custom scheduler running for the App Engine. But I see how they contrast those regularly scheduled “cron” jobs versus a task queue (https://cloud.google.com/appengine/docs/standard/python/taskqueue/) although Google’s implementation uses “due dates” to let you do a one-off type of scheduling. 

 

Ultimately, it depends on how fine grained you want things to be. I suppose you could have cronjobs set up daily, hourly, monthly, and weekly (using cron.daily/cron.hourly/cron.monthly/cron.weekly… although I think some OSes use anacron for some of these?) and then have those poll the Koha database for a “cron” table where plugins and such can configure jobs. I mean… it would be the “lighest touch”. Like I said above,you’d want to think about locking, but other than that… it would work. 

 

Maybe a mix of all the above…

 

David Cook

Systems Librarian

Prosentient Systems

72/330 Wattle St

Ultimo, NSW 2007

Australia

 

Office: 02 9212 0899

Direct: 02 8005 0595

 

From: koha-devel-bounces at lists.koha-community.org [mailto:koha-devel-bounces at lists.koha-community.org] On Behalf Of Nick Clemens
Sent: Friday, 8 June 2018 3:48 AM
To: Koha Devel <koha-devel at lists.koha-community.org>
Subject: [Koha-devel] Cronjob to run plugin cronjobs?

 

Just an idea I had an bounced off Kyle, he suggested sending it out for feedback, let us knwo what you think:

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20897

-- 

Nick Clemens

Sonic Screwdriver (Development Support)

ByWater Solutions

IRC: kidclamp

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20180608/450f6c79/attachment.html>


More information about the Koha-devel mailing list