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.")); }
KEY SerieTime (SerieTime) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED; EOD; Console::stdout(PHP_EOL); Console::stdout(PHP_EOL); if (Console::confirm('%YDo you want to install the database?%n')) { if (Console::confirm('%RAre you sure? ( all data in ' . $DB_NAME . ' WILL BE LOST! )%n')) { $query = str_replace(array_keys($vars), array_values($vars), $SQLDB); $query = str_replace(PHP_EOL, '', $query); if (!$mysqli->multi_query($query)) { Console::stdout('There was an error installing the database' . PHP_EOL); Console::stdout('ERR.(' . $mysqli->errno . ") " . $mysqli->error . PHP_EOL); exit(0); } } } Console::stdout('%Y## WRITE CONFIG GLOBAL ##%n' . PHP_EOL . PHP_EOL); $configfile = $f3->get('CONFIG_DIR') . '/config.globals.ini'; touch($configfile); file_put_contents($configfile, str_replace(array_keys($vars), array_values($vars), $config_global)); Console::stdout('%Y## WRITE CONFIG MASTER ##%n' . PHP_EOL . PHP_EOL); $configfile = $f3->get('CONFIG_DIR') . '/config.master.ini'; touch($configfile); file_put_contents($configfile, str_replace(array_keys($vars), array_values($vars), $config_master)); Console::stdout('%G## ALL DONE! ##%n' . PHP_EOL . PHP_EOL); Console::stdout('Now you can test Saturn-Master installation.' . PHP_EOL . PHP_EOL); Console::stdout('Type this command to check if everything is working :' . PHP_EOL); Console::stdout("#" . $f3->get('BASE_DIR') . '/app-bin/master.php start' . PHP_EOL . PHP_EOL); exit(0); }); $f3->run();
/** * 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)); }
protected static function log($msg) { Console::stdout($msg . PHP_EOL); }
<?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()); }