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

[8.x] Adds "schedule:work" command #34618

Merged
merged 4 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

class ScheduleWorkCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'schedule:work';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Start the schedule worker';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->info('Schedule worker started successfully.');

while (true) {
if (Carbon::now()->second === 0) {
$this->call('schedule:run');
}

sleep(1);
}
}
}
12 changes: 12 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Cache\Console\ForgetCommand as CacheForgetCommand;
use Illuminate\Console\Scheduling\ScheduleFinishCommand;
use Illuminate\Console\Scheduling\ScheduleRunCommand;
use Illuminate\Console\Scheduling\ScheduleWorkCommand;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Database\Console\DumpCommand;
use Illuminate\Database\Console\Factories\FactoryMakeCommand;
Expand Down Expand Up @@ -113,6 +114,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'Seed' => 'command.seed',
'ScheduleFinish' => ScheduleFinishCommand::class,
'ScheduleRun' => ScheduleRunCommand::class,
'ScheduleWork' => ScheduleWorkCommand::class,
'StorageLink' => 'command.storage.link',
'Up' => 'command.up',
'ViewCache' => 'command.view.cache',
Expand Down Expand Up @@ -914,6 +916,16 @@ protected function registerScheduleRunCommand()
$this->app->singleton(ScheduleRunCommand::class);
}

/**
* Register the command.
*
* @return void
*/
protected function registerScheduleWorkCommand()
{
$this->app->singleton(ScheduleWorkCommand::class);
}

/**
* Register the command.
*
Expand Down