#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../bootstrap.php';
use Hodor\Command\Arguments;
use Hodor\Config\LoaderFacade as Config;
use Hodor\Daemon\ManagerFactory;
$args = new Arguments();
$config_file = $args->getConfigFile();
$config = Config::loadFromFile($config_file);
$daemonizer = new ManagerFactory($config);
$manager = $daemonizer->getManager();
if ($args->isJson()) {
    echo json_encode($manager->getDaemonConfig()) . "\n";
} else {
    $manager->setupDaemon();
}
Beispiel #2
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../bootstrap.php';
use Hodor\Command\Arguments;
use Hodor\Config\LoaderFacade as Config;
use Hodor\JobQueue\QueueManager;
$args = new Arguments();
$config_file = $args->getConfigFile();
$queue_name = $args->getQueueName();
$config = Config::loadFromFile($config_file);
$queue_manager = new QueueManager($config);
$worker_queue = $queue_manager->getWorkerQueueFactory()->getQueue($queue_name);
$worker_queue->runNext($config->getJobQueueConfig()->getJobRunnerFactory());
Beispiel #3
0
 /**
  * @param array $return_value
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 private function getArgumentsObject(array $return_value)
 {
     $arguments = new Arguments();
     $arguments->setCliOptsLoader(function () use($return_value) {
         return $return_value;
     });
     return $arguments;
 }
Beispiel #4
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../bootstrap.php';
use Hodor\Command\Arguments;
use Hodor\Config\LoaderFacade as Config;
use Hodor\JobQueue\QueueManager;
$args = new Arguments();
$config_file = $args->getConfigFile();
$config = Config::loadFromFile($config_file);
$queue_manager = new QueueManager($config);
$superqueue = $queue_manager->getSuperqueue();
if (!$superqueue->requestProcessLock()) {
    sleep(5);
} elseif (!$superqueue->queueJobsFromDatabaseToWorkerQueue()) {
    sleep(2);
}
Beispiel #5
0
#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
use Hodor\JobQueueFacade as Q;
use Hodor\Command\Arguments;
$args = new Arguments();
$config_file = $args->getConfigFile();
$queue_name = $args->getQueueName();
$job_name = $args->getJobName();
$job_params = $args->getJobParams();
$job_options = ['queue_name' => $queue_name];
if (!empty($job_params['job_options']['run_after'])) {
    $job_options['run_after'] = new \DateTime($job_params['job_options']['run_after']);
}
if (!empty($job_params['job_options']['job_rank'])) {
    $job_options['job_rank'] = $job_params['job_options']['job_rank'];
}
if (!empty($job_params['job_options']['mutex_id'])) {
    $job_options['mutex_id'] = $job_params['job_options']['mutex_id'];
}
Q::setConfigFile($config_file);
Q::push($job_name, $job_params, $job_options);