Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class ProcessManager |
||
6 | { |
||
7 | 4 | public function isStillRunning(int $processId): bool |
|
10 | } |
||
11 | |||
12 | 3 | public function startProcess( |
|
13 | string $phpPath, |
||
14 | string $queueName, |
||
15 | ?string $connection, |
||
16 | bool $specifyQueue, |
||
17 | int $timeout, |
||
18 | int $sleep, |
||
19 | int $tries |
||
20 | ): int { |
||
21 | 3 | $command = $phpPath; |
|
22 | 3 | $command .= ' artisan queue:work'; |
|
23 | |||
24 | 3 | if (null !== $connection) { |
|
25 | 1 | $command .= ' ' . $connection; |
|
26 | } |
||
27 | |||
28 | 3 | if ($specifyQueue) { |
|
29 | 3 | $command .= ' --queue ' . $queueName; |
|
30 | } |
||
31 | |||
32 | 3 | $command .= ' --timeout ' . $timeout; |
|
33 | 3 | $command .= ' --sleep ' . $sleep; |
|
34 | 3 | $command .= ' --tries ' . $tries; |
|
35 | |||
36 | // Suppress output and return PID |
||
37 | 3 | $command .= ' > /dev/null & echo $!'; |
|
38 | |||
39 | 3 | return (int) exec( |
|
40 | 3 | $command |
|
41 | ); |
||
42 | } |
||
43 | |||
44 | 2 | public function killProcess(int $processId): void |
|
47 | 2 | } |
|
48 | } |
||
49 |