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

Allow calling cron jobs background job class with occ #30359

Merged
merged 12 commits into from
May 6, 2024

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Dec 21, 2021

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

@juliushaertl
Copy link
Member Author

Might be something related to #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

@solracsf
Copy link
Member

This can also help in this cases: #30273

@szaimen szaimen added 3. to review Waiting for reviews enhancement labels Jan 31, 2022
@szaimen szaimen added this to the Nextcloud 24 milestone Jan 31, 2022
@skjnldsv skjnldsv mentioned this pull request Mar 24, 2022
@blizzz blizzz mentioned this pull request Mar 31, 2022
This was referenced Apr 7, 2022
@PVince81
Copy link
Member

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

@juliushaertl
Copy link
Member Author

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

core/Command/Background/Worker.php Fixed Show fixed Hide fixed
core/Command/Background/Worker.php Fixed Show fixed Hide fixed
core/Command/Background/Worker.php Fixed Show fixed Hide fixed
This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
@CarlSchwan CarlSchwan changed the title Allow calling cron.php with a background job class Allow calling cron jobs background job class with occ Sep 5, 2022
Comment on lines 98 to 100
if ((int)$row['count'] === 1) {
$count++;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

core/Command/Background/Worker.php Outdated Show resolved Hide resolved
core/Command/Background/Worker.php Outdated Show resolved Hide resolved
core/Command/Background/Worker.php Outdated Show resolved Hide resolved
lib/private/BackgroundJob/JobList.php Outdated Show resolved Hide resolved
@julien-nc julien-nc marked this pull request as ready for review April 18, 2024 09:10
@susnux susnux added this to the Nextcloud 30 milestone Apr 18, 2024
@julien-nc julien-nc force-pushed the enh/background-job-class branch 2 times, most recently from f24e031 to 7f39075 Compare April 23, 2024 09:41
@skjnldsv
Copy link
Member

skjnldsv commented May 2, 2024

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

@julien-nc julien-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress stale Ticket or PR with no recent activity labels May 2, 2024
juliushaertl and others added 12 commits May 2, 2024 16:43
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…ss in cron.php and the job worker occ command

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…und-job:worker for the job class list

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@marcelklehr marcelklehr merged commit d1ed8bd into master May 6, 2024
157 checks passed
@marcelklehr marcelklehr deleted the enh/background-job-class branch May 6, 2024 08:23
@juliushaertl
Copy link
Member Author

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

* @return list<array{class:class-string, count:int}>
* @since 30.0.0
*/
public function countByClass(): array;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blizzz blizzz mentioned this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.