Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
This repository was 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

Description

@leo108

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();

Activity

tomschlick

tomschlick commented on Mar 7, 2017

@tomschlick

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

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

leo108 commented on Mar 7, 2017

@leo108
Author

@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

tomschlick commented on Mar 7, 2017

@tomschlick

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

tomschlick commented on Mar 7, 2017

@tomschlick

Just added a PR for it! :)

tomschlick

tomschlick commented on Mar 7, 2017

@tomschlick

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tomschlick@leo108

        Issue actions

          [Proposal] Add an option to convert scheduled task commands to queue jobs · Issue #457 · laravel/ideas