• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / workbench / 24076123284

07 Apr 2026 10:11AM UTC coverage: 89.74% (-3.3%) from 93.005%
24076123284

push

github

web-flow
[10.x] Overrides `schedule:work` command (#107)

fixes orchestral/testbench-core#395

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

1 of 24 new or added lines in 2 files covered. (4.17%)

586 of 653 relevant lines covered (89.74%)

17.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Console/ScheduleWorkCommand.php
1
<?php
2

3
namespace Orchestra\Workbench\Console;
4

5
use Illuminate\Console\Application;
6
use Illuminate\Console\Command;
7
use Illuminate\Support\Carbon;
8
use Illuminate\Support\ProcessUtils;
9
use Symfony\Component\Console\Attribute\AsCommand;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Process\Process;
12

13
use function Orchestra\Sidekick\working_path;
14

15
#[AsCommand(name: 'schedule:work')]
16
class ScheduleWorkCommand extends Command
17
{
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'schedule:work
24
        {--run-output-file= : The file to direct <info>schedule:run</info> output to}
25
        {--whisper : Do not output message indicating that no jobs were ready to run}';
26

27
    /**
28
     * The console command description.
29
     *
30
     * @var string
31
     */
32
    protected $description = 'Start the schedule worker';
33

34
    /**
35
     * Execute the console command.
36
     *
37
     * @return never
38
     */
39
    public function handle()
40
    {
NEW
41
        $this->components->info(
×
NEW
42
            'Running scheduled tasks.',
×
NEW
43
            $this->getLaravel()->environment('local') ? OutputInterface::VERBOSITY_NORMAL : OutputInterface::VERBOSITY_VERBOSE
×
NEW
44
        );
×
45

NEW
46
        [$lastExecutionStartedAt, $executions] = [Carbon::now()->subMinutes(10), []];
×
47

NEW
48
        $command = Application::formatCommandString('schedule:run');
×
49

NEW
50
        if ($this->option('whisper')) {
×
NEW
51
            $command .= ' --whisper';
×
52
        }
53

NEW
54
        if ($this->option('run-output-file')) {
×
NEW
55
            $command .= ' >> '.ProcessUtils::escapeArgument($this->option('run-output-file')).' 2>&1';
×
56
        }
57

NEW
58
        while (true) {
×
NEW
59
            usleep(100 * 1000);
×
60

NEW
61
            if (Carbon::now()->second === 0 &&
×
NEW
62
                ! Carbon::now()->startOfMinute()->equalTo($lastExecutionStartedAt)) {
×
NEW
63
                $executions[] = $execution = Process::fromShellCommandline($command, working_path());
×
64

NEW
65
                $execution->start();
×
66

NEW
67
                $lastExecutionStartedAt = Carbon::now()->startOfMinute();
×
68
            }
69

NEW
70
            foreach ($executions as $key => $execution) {
×
NEW
71
                $output = $execution->getIncrementalOutput().
×
NEW
72
                    $execution->getIncrementalErrorOutput();
×
73

NEW
74
                $this->output->write(ltrim($output, "\n"));
×
75

NEW
76
                if (! $execution->isRunning()) {
×
NEW
77
                    unset($executions[$key]);
×
78
                }
79
            }
80
        }
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc