protected function stop() { Console::stdout('Stopping... '); try { if (!D::isRunning($this->pid_file)) { Console::output('%y[Daemon not running]%n'); } else { D::kill($this->pid_file, true); Console::output('%g[OK]%n'); } } catch (\Exception $ex) { Console::output('%r[FAILED]%n'); } }
/** * Action to set the new environment. * * It's just the copying of the config overrides * from <entry_point>/config/environments/<id>.php to <entry_point>/config/overrides/environment.php * This action automates this mundane task. * * @param string $id ID of the environment to set. */ public function actionSet($id) { foreach ($this->config_dirs as $dir) { $source = "{$dir}/environments/{$id}.php"; if (!file_exists($source)) { Console::output($this->note("No config file found for this environment in ") . $this->value($dir) . "."); continue; } $destination = $dir . '/overrides/environment.php'; $conversion_report = sprintf("%s\n => %s ...", str_replace(ROOT_DIR . '/', '', $source), str_replace(ROOT_DIR . '/', '', $destination)); Console::stdout($conversion_report); // no EOL, please // WARNING: current `config/overrides/environment.php` will be ERASED! copy($source, $destination); Console::output("done."); } Console::output($this->note("Operation completed.")); }
/** * Copy environment specific config file to main-env.php for each config directory * @param $env */ private function createEnvConfigs($env) { Console::output("%yCreate environment config files:%n"); foreach ($this->configDirs as $dir) { $source = "{$dir}/environments/{$env}.php"; if (file_exists($this->root . $source)) { $destination = $dir . '/main-env.php'; Console::output("%gCopy:%n\t\t{$source} => {$destination}"); copy($this->root . $source, $this->root . $destination); } else { Console::output("%wNot found:%n\t{$source}"); } $localConf = $this->root . $dir . '/main-local.php'; if (!file_exists($localConf)) { file_put_contents($localConf, '<?php' . PHP_EOL); Console::output("%gCreate:%n\t\t{$dir}/main-local.php"); } } Console::output(""); }
private function help() { Console::output(''); Console::output('%_Usage:%n ckfqmanager (--config|-c) <configfile> [--debug] <action>'); Console::output(''); Console::output('Valid Actions:'); Console::output('=============='); Console::output(' %_stats%n - Show statistics of the queue.'); Console::output(' %_add%n - Add to queue. Include: --worker <comma separated name of workers> --data <json format of data>'); Console::output(' %_work%n - Work the next item in the queue.'); Console::output(' %_peek%n - Have a look in the next item in the queue & release it back into the queue.'); Console::output(' %_pop%n - Remove the next item in the queue.'); Console::output(' %_flush%n - Flush all items in the queue.'); Console::output(''); }
public function _log($type, $color, $background, $msg) { Console::output($color . $background . $msg . '%n'); call_user_func_array(array($this->log, "add" . ucfirst($type)), array($msg)); }
<?php require_once 'config.php'; use Clio\Console; use CKFQueue\Base as CKFQ; try { CKFQ::addJob(array('Hello'), array('name' => "Michael", "email" => "*****@*****.**")); CKFQ::addJob(array('Hello'), array('name' => "Susan", "email" => "*****@*****.**")); CKFQ::addJob(array('Hello'), array('name' => "Cherryanne", "email" => "*****@*****.**")); Console::output("Successfully added 3 jobs."); } catch (Exception $ex) { Console::output("Failed to add to queue: " . $ex->getMessage()); }