run-job 490 B

123456789101112131415161718192021
  1. #!/usr/bin/env php
  2. <?php
  3. if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
  4. require_once __DIR__ . '/../vendor/autoload.php';
  5. } else {
  6. require_once __DIR__ . '/../../../autoload.php';
  7. }
  8. parse_str($argv[2], $config);
  9. $cls = $config['jobClass'];
  10. if (!is_a($cls, 'Jobby\BackgroundJob', true)) {
  11. throw new Jobby\Exception('"jobClass" needs to be an instanceof Jobby\BackgroundJob');
  12. }
  13. /** @var \Jobby\BackgroundJob $job */
  14. $job = new $cls($argv[1], $config);
  15. $job->run();