Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

[Proposal] Add an option to convert scheduled task commands to queue jobs #457

Closed
leo108 opened this issue Mar 6, 2017 · 5 comments
Closed

Comments

@leo108
Copy link

leo108 commented Mar 6, 2017

The purpose of this proposal is to create an easier way to balance scheduled tasks between multiple servers.

We can only set up the schedule:run cronjob in only one server right now, if there are many big scheduled tasks in a project, the server load of cronjob server may become very high and slow down the tasks which may cause unexpected problems.

For current version of Laravel (5.4), we can create a job that implements ShouldQueue and create an artisan command that triggers the job to do what we want, but why not provide an easier way to do this?

For example, we make an artisan command class implements ShouldQueue, when schedule:run triggered, it finds that the scheduled task implements ShouldQueue, then it dispatches a built-in job called RunScheduledTaskJob.

Or add a method called queue to Illuminate\Console\Scheduling\Event class, so that we can define a scheduled task by

$schedule->command('foo:bar')->queue($queueName)->everyThirtyMinutes();
@tomschlick
Copy link

It might be better just to eliminate the middleman there and allow the scheduling of jobs directly...

$schedule->job(new JobNameHere())->everyThirtyMinutes();

@leo108
Copy link
Author

leo108 commented Mar 7, 2017

@tomschlick good idea, but sometimes we may need to run the scheduled task manually, so I think we still need a way to convert artisan command to queue job.

@tomschlick
Copy link

I'm going to look into this tonight to see how viable it is... I really like this as I have a few commands that only exist to throw jobs in the queue every X minutes.

@tomschlick
Copy link

Just added a PR for it! :)

@tomschlick
Copy link

PR was merged. This can prob be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants