Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 621
Zeile 2... Zeile 2...
2
 
2
 
Zeile 3... Zeile 3...
3
namespace Illuminate\Console\Scheduling;
3
namespace Illuminate\Console\Scheduling;
4
 
4
 
-
 
5
use Illuminate\Console\Command;
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Carbon;
-
 
7
use Illuminate\Support\ProcessUtils;
6
use Illuminate\Support\Carbon;
8
use Symfony\Component\Console\Attribute\AsCommand;
Zeile 7... Zeile 9...
7
use Symfony\Component\Console\Attribute\AsCommand;
9
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Process\Process;
10
use Symfony\Component\Process\Process;
9
 
11
 
10
#[AsCommand(name: 'schedule:work')]
12
#[AsCommand(name: 'schedule:work')]
11
class ScheduleWorkCommand extends Command
13
class ScheduleWorkCommand extends Command
12
{
14
{
13
    /**
15
    /**
14
     * The console command name.
16
     * The name and signature of the console command.
15
     *
17
     *
Zeile 16... Zeile 18...
16
     * @var string
18
     * @var string
17
     */
19
     */
18
    protected $name = 'schedule:work';
20
    protected $signature = 'schedule:work {--run-output-file= : The file to direct <info>schedule:run</info> output to}';
19
 
21
 
Zeile 40... Zeile 42...
40
     *
42
     *
41
     * @return void
43
     * @return void
42
     */
44
     */
43
    public function handle()
45
    public function handle()
44
    {
46
    {
-
 
47
        $this->components->info(
45
        $this->components->info('Running schedule tasks every minute.');
48
            'Running scheduled tasks every minute.',
-
 
49
            $this->getLaravel()->isLocal() ? OutputInterface::VERBOSITY_NORMAL : OutputInterface::VERBOSITY_VERBOSE
-
 
50
        );
Zeile 46... Zeile 51...
46
 
51
 
Zeile -... Zeile 52...
-
 
52
        [$lastExecutionStartedAt, $executions] = [null, []];
-
 
53
 
-
 
54
        $command = implode(' ', array_map(fn ($arg) => ProcessUtils::escapeArgument($arg), [
-
 
55
            PHP_BINARY,
-
 
56
            defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
-
 
57
            'schedule:run',
-
 
58
        ]));
-
 
59
 
-
 
60
        if ($this->option('run-output-file')) {
-
 
61
            $command .= ' >> '.ProcessUtils::escapeArgument($this->option('run-output-file')).' 2>&1';
47
        [$lastExecutionStartedAt, $executions] = [null, []];
62
        }
48
 
63
 
Zeile 49... Zeile 64...
49
        while (true) {
64
        while (true) {
50
            usleep(100 * 1000);
65
            usleep(100 * 1000);
51
 
66
 
52
            if (Carbon::now()->second === 0 &&
-
 
53
                ! Carbon::now()->startOfMinute()->equalTo($lastExecutionStartedAt)) {
-
 
54
                $executions[] = $execution = new Process([
-
 
55
                    PHP_BINARY,
-
 
Zeile 56... Zeile 67...
56
                    defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
67
            if (Carbon::now()->second === 0 &&
Zeile 57... Zeile 68...
57
                    'schedule:run',
68
                ! Carbon::now()->startOfMinute()->equalTo($lastExecutionStartedAt)) {
58
                ]);
69
                $executions[] = $execution = Process::fromShellCommandline($command);
Zeile 59... Zeile 70...
59
 
70
 
60
                $execution->start();
71
                $execution->start();
61
 
72
 
Zeile 62... Zeile 73...
62
                $lastExecutionStartedAt = Carbon::now()->startOfMinute();
73
                $lastExecutionStartedAt = Carbon::now()->startOfMinute();
Zeile 63... Zeile 74...
63
            }
74
            }
64
 
75