You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
734 B
PHP
29 lines
734 B
PHP
<?php
|
|
namespace App\Command;
|
|
|
|
use App\Services\Cloud\CloudWorkerService;
|
|
|
|
final class CloudWorker
|
|
{
|
|
public static function run(array $argv = []): int
|
|
{
|
|
$once = in_array('--once', $argv, true);
|
|
$worker = new CloudWorkerService();
|
|
do {
|
|
try {
|
|
$worked = $worker->tick();
|
|
} catch (\Throwable $error) {
|
|
fwrite(STDERR, 'cloud worker temporarily unavailable: ' . get_class($error) . PHP_EOL);
|
|
if ($once) {
|
|
return 1;
|
|
}
|
|
$worked = false;
|
|
}
|
|
if (!$once && !$worked) {
|
|
usleep(1000000);
|
|
}
|
|
} while (!$once);
|
|
return 0;
|
|
}
|
|
}
|