server icon indicating copy to clipboard operation
server copied to clipboard

Allow calling cron jobs background job class with occ

Open juliusknorr opened this issue 3 years ago • 4 comments

This would allow important jobs to be handled in a separate cronjob execution, so they can get executed, even if other jobs have lined up before

e.g. have a separate cron job with php occ background-job:worker OCA\\Files\\BackgroundJob\\ScanFiles

juliusknorr avatar Dec 21 '21 08:12 juliusknorr

Might be something related to https://github.com/nextcloud/server/issues/29204 to have also an occ command to run individual job classes in addition to the list. This would be similar to how Laravel handles queues https://laravel.com/docs/8.x/queues some further things to think about:

  • group multiple classes by their domain/importance
  • have a worker occ command that could be setup as a continuous runner

juliusknorr avatar Dec 22 '21 07:12 juliusknorr

This can also help in this cases: https://github.com/nextcloud/server/issues/30273

solracsf avatar Dec 26 '21 18:12 solracsf

we already have background-job:execute but I heard it doesn't work for all types and requires a job id, not a class name

PVince81 avatar Apr 14 '22 18:04 PVince81

Sounds like a good idea to rather implement it as an occ which people could still setup as a cron job then.

juliusknorr avatar Apr 20 '22 14:04 juliusknorr

  • [ ] tests

marcelklehr avatar Dec 20 '23 13:12 marcelklehr

Please rebase :)

skjnldsv avatar Feb 27 '24 16:02 skjnldsv

Rebased on master, made a few minor changes, added -h option to cron.php, more output in the background job worker. Tested the background job worker, LGTM. This will greatly help to improve the user experience when running data processing tasks like text processing, speech-to-text etc...

julien-nc avatar Apr 08 '24 11:04 julien-nc

Would it be possible to pass a list of job classes to run? That way we can avoid overloading a GPU (if there's only one) with tasks from multiple different background job daemons

marcelklehr avatar Apr 08 '24 11:04 marcelklehr

@marcelklehr Nice idea, I added it in this PR for both cron.php and the occ background-job:worker command. Anything else we should add/change before making this ready for reviews?

julien-nc avatar Apr 08 '24 15:04 julien-nc

Still stale @julien-nc ? Please adjust labels :)

skjnldsv avatar May 02 '24 14:05 skjnldsv

Thanks @marcelklehr and @julien-nc for picking this one up. 🚀

juliusknorr avatar May 06 '24 19:05 juliusknorr