Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class WorkCommand extends ProcessManagerCommand |
||
11 | { |
||
12 | protected $signature = 'table_sync:work'; |
||
13 | protected $description = 'Run table_sync worker'; |
||
14 | |||
15 | public function __destruct() |
||
18 | } |
||
19 | |||
20 | public function handle(Consumer $consumer): void |
||
21 | { |
||
22 | if ($this->pidManager->pidExists()) { |
||
23 | $this->warn("Table sync worker already running (PID: {$this->pidManager->readPid()})"); |
||
24 | return; |
||
25 | } |
||
26 | |||
27 | $this->pidManager->writePid(); |
||
28 | $this->listenTerminateSignals($consumer); |
||
29 | |||
30 | $consumer->consume(); |
||
31 | } |
||
32 | |||
33 | private function listenTerminateSignals(Consumer $consumer): void |
||
47 | }); |
||
48 | } |
||
50 |