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

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

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

Comments

Projects
None yet
2 participants
@leo108

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

This comment has been minimized.

tomschlick commented Mar 7, 2017

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

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

This comment has been minimized.

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

This comment has been minimized.

tomschlick commented Mar 7, 2017

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

This comment has been minimized.

tomschlick commented Mar 7, 2017

Just added a PR for it! :)

@tomschlick

This comment has been minimized.

tomschlick commented Mar 7, 2017

PR was merged. This can prob be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment