コード例 #1
0
ファイル: Fresque.php プロジェクト: neoseeker/fresque
 private function clearWorker()
 {
     \Resque::Redis()->del('ResqueWorker');
 }
コード例 #2
0
ファイル: Fresque.php プロジェクト: RTBF/Fresque
 /**
  *
  * @since  1.2.0
  * @return  void
  */
 public function callCommand($command)
 {
     if (($settings = $this->loadSettings($command)) === false) {
         exit(1);
     }
     $args = $this->input->getArguments();
     $globalOptions = array('s' => 'host', 'p' => 'port', 'b' => 'path', 'c' => 'path', 'a' => 'path', 'd' => 'handler', 'r' => 'args,');
     if ($command === null || !array_key_exists($command, $this->commandTree)) {
         $this->help($command);
     } else {
         if ($this->input->getOption('help')->value === true) {
             $this->output->outputLine();
             $this->output->outputLine($this->commandTree[$command]['help']);
             if (!empty($this->commandTree[$command]['options'])) {
                 $this->output->outputLine("\nAvailable options\n", 'subtitle');
                 foreach ($this->commandTree[$command]['options'] as $name => $arg) {
                     $opt = $this->input->getOption(is_numeric($name) ? $arg : $name);
                     $o = (!empty($opt->short) ? '-' . $opt->short : '  ') . ' ' . (is_numeric($name) ? '' : '<' . $arg . '>');
                     $this->output->outputLine(sprintf('%-15s --%-15s %s', $o, $opt->long, $opt->longhelp));
                 }
             }
             $this->output->outputLine("\nGlobal options\n", 'subtitle');
             foreach ($globalOptions as $name => $arg) {
                 $opt = $this->input->getOption(is_numeric($name) ? $arg : $name);
                 $o = '-' . $opt->short . ' ' . (is_numeric($name) ? '' : '<' . $arg . '>');
                 $this->output->outputLine(sprintf('%-15s --%-15s %s', $o, $opt->long, $opt->longhelp));
             }
             $this->output->outputLine();
         } else {
             $allowed = array_merge($this->commandTree[$command]['options'], $globalOptions);
             foreach ($allowed as $name => &$arg) {
                 if (!is_numeric($name)) {
                     $arg = $name;
                 }
             }
             $unrecognized = array_diff(array_keys($this->input->getOptionValues()), array_values($allowed));
             if (!empty($unrecognized)) {
                 $this->output->outputLine('Invalid options ' . implode(', ', array_map(function ($opt) {
                     return '-' . $opt;
                 }, $unrecognized)) . ' will be ignored', 'warning');
             }
             call_user_func_array(self::$Resque . '::setBackend', array($this->runtime['Redis']['host'] . ':' . $this->runtime['Redis']['port'], $this->runtime['Redis']['database'], $this->runtime['Redis']['namespace']));
             if ($this->runtime['Scheduler']['enabled'] === true) {
                 require_once realpath($this->runtime['Scheduler']['lib'] . DS . 'lib' . DS . 'ResqueScheduler' . DS . 'ResqueScheduler.php');
                 require_once realpath($this->runtime['Scheduler']['lib'] . DS . 'lib' . DS . 'ResqueScheduler' . DS . 'Stat.php');
             }
             $this->ResqueStatus = new \ResqueStatus\ResqueStatus(\Resque::Redis());
             $this->ResqueStats = new ResqueStats(\Resque::Redis());
             $this->{$command}();
         }
     }
 }
コード例 #3
0
ファイル: Redis.php プロジェクト: ztongle/yii2-resque
 public static function get($jobId)
 {
     $data = Resque::Redis()->get('failed:' . $jobId);
     return unserialize($data);
 }