public function __construct($database, Loops $loops = NULL) { parent::__construct($loops); // Get config from Loops redis service $config = Redis::getConfig($this->getLoops()); // Set Backend information \Resque::setBackend("{$config->host}:{$config->port}", (int) $database); }
public function init_resqueSchedulerWorkerFlags($flags) { // Get config from Loops redis service $config = $this->getLoops()->getService("config"); $redis_config = RedisService::getConfig($this->getLoops()); $resque_config = ResqueService::getConfig($this->getLoops()); $config = $config->offsetExists("resque_scheduler_worker") ? $config->offsetGet("resque_scheduler_worker") : new ArrayObject(); // Set default values $redis_backend = $config->offsetExists("redis_backend") ? $config->offsetGet("redis_backend") : (getenv("REDIS_BACKEND") ?: "{$redis_config->host}:{$redis_config->port}"); $redis_database = $config->offsetExists("redis_database") ? $config->offsetGet("redis_database") : ($resque_config->offsetGet("database") ?: getenv("REDIS_DATABASE")); $interval = $config->offsetExists("interval") ? $config->offsetGet("interval") : (getenv("INTERVAL") ?: 5); $logging = $config->offsetExists("logging") ? $config->offsetGet("logging") : (bool) (getenv("LOGGING") || getenv("VERBOSE") || getenv("VVERBOSE")); $verbose = $config->offsetExists("verbose") ? $config->offsetGet("verbose") : (bool) getenv("VVERBOSE"); // Define options $flags->string("redis-backend", $redis_backend, "Connection string for the redis backend. [Default: {$redis_backend}]"); $flags->int("redis-database", $redis_database, "The Redis database to connect to. [Default: {$redis_database}]"); $flags->string("interval", $interval, "The polling interval of the workers in seconds. [Default: {$interval}]"); $flags->short("l", "Enable logging of workers." . ($logging ? " [Enabled by config]" : "")); $flags->short("v", "Use verbose logging of workers." . ($verbose ? " [Enabled by config]" : "")); //for the resqueSchedulerWorker action $this->logging = $logging; $this->verbose = $verbose; }