public function init() { parent::init(); Yii::getLogger()->autoFlush = 10; Yii::getLogger()->detachEventHandler('onFlush', array(Yii::app()->log, 'collectLogs')); Yii::getLogger()->attachEventHandler('onFlush', array($this, 'processLogs')); }
public function __construct($name, $runner) { parent::__construct($name, $runner); if ($this->_log == null) { $this->_log = new CronFileLogRoute('command_update'); } }
/** * Ini system param */ public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); $this->_logger = LoggerFactory::getFileLogger('process_sync_db'); }
/** * Pluralize word depending on count * * @param string $name * @param int $count * @return string */ public function pluralize($name, $count = 1) { if ($count == 1) { return $name; } return parent::pluralize($name); }
public function run($args) { \Yii::getLogger()->autoFlush = 1; \Yii::getLogger()->detachEventHandler('onFlush', [\Yii::app()->log, 'collectLogs']); \Yii::getLogger()->attachEventHandler('onFlush', [$this, 'processLogs']); parent::run($args); }
/** * Initialize the command object. */ public function init() { // Tell yii to flush the logs every message (instead of buffering for the default 10,000) // Without this, you cannot use the log to find out where the script has got to in it's current run. Yii::getLogger()->autoFlush = 1; Yii::getLogger()->autoDump = true; parent::init(); }
/** * GenerateWorklistsCommand constructor. * * @param string $name * @param CConsoleCommandRunner $runner * @param WorklistManager $manager */ public function __construct($name, $runner, $manager = null) { if (is_null($manager)) { $manager = new WorklistManager(); } $this->manager = $manager; parent::__construct($name, $runner); }
protected function afterAction($action, $params, $exitCode = 0) { if (isset($this->service['name'])) { $this->log("SERVICE: Service {$this->service['name']} exited with code {$exitCode} [PID: {$this->pid}] "); ServiceManager::markAsStopped($this->service['name'], $this->id); } return parent::afterAction($action, $params, $exitCode); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); $this->_logger = LoggerFactory::getFileLogger('sms'); // $this->_logger = LoggerFactory::getConsoleLogger(); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); // All reports are generated basing on data in UTC time. TimezoneWork::set('UTC'); }
public function afterAction($action, $params, $exitCode = 0) { if ($this->outputLog) { echo implode("\n", $this->_log) . "\n"; } array_unshift($this->_log, 'Launched at: ' . date("Y-m-d H:i:s")); file_put_contents(Yii::app()->params['logDirPath'] . '/moveFollowUpAppointment.log', implode("\n", $this->_log), FILE_APPEND); return parent::afterAction($action, $params, $exitCode); }
/** * Load and render the view * * @param $view view file path (yii path alias) * @param null $data parameters to render in the view * @return string the rendered view * @throws CException if the view cannot be found */ public function renderPartial($view, $data = null) { if (($viewFile = $this->getViewFile($view)) !== false) { $output = CConsoleCommand::renderFile($viewFile, $data, true); return $output; } else { throw new CException(Yii::t('yii', '{controller} cannot find the requested view "{view}".', array('{controller}' => get_class($this), '{view}' => $view))); } }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); self::$_logger = LoggerFactory::getFileLogger('reports'); // All reports are generated basing on data in UTC time. TimezoneWork::set('UTC'); }
public function init() { parent::init(); Yii::import('application.modules.yupe.components.*'); Yii::import('application.modules.yupe.models.*'); Yii::import('application.modules.comment.models.*'); $this->migrator = is_object($this->migrator) ? $this->migrator : new Migrator(); $this->db = is_object($this->db) ? $this->db : Yii::app()->db; }
public function beforeAction($action, $params) { $path = Yii::getPathOfAlias($this->migrationPath); if ($path === false || !is_dir($path)) { echo 'Error: The migration directory does not exist: ' . $this->migrationPath . "\n"; exit(1); } $this->migrationPath = $path; return parent::beforeAction($action, $params); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); ini_set('display_errors', '1'); set_time_limit(0); error_reporting(E_ALL); $this->_logger = LoggerFactory::getFileLogger('poller'); // $this->_logger = LoggerFactory::getConsoleLogger(); // For testing }
public function __construct($id, $module = null) { parent::__construct($id, $module); $this->product_model = new Product(); $this->productType_model = new ProductType(); $this->productPublish_model = new ProductPublish(); $this->userProductBuy_model = new UserProductBuy(); $this->buyLogs_model = new BuyLogs(); $this->tradingRecord_model = new TradingRecord(); $this->userInfo_model = new Userinfo(); }
/** * Determine if the command should use colors, if you overwrite this method * remember to return the parent value. * @param string $action the action name * @param array $params the parameters to be passed to the action method. * @return bool whether the action should be executed. */ protected function beforeAction($action, $params) { $this->shouldUseColors = true; if (function_exists('posix_isatty')) { $this->shouldUseColors = posix_isatty(STDOUT); } if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $this->shouldUseColors = false; } return parent::beforeAction($action, $params); }
/** * (non-PHPdoc) * @see CConsoleCommand::afterAction() */ protected function afterAction($action, $params, $exitCode = 0) { $dirPath = Yii::app()->runtimePath . '/locks/'; $commandName = $this->getName(); $lockFileName = "{$commandName}_{$action}_.lock"; $lockFilePath = $dirPath . $lockFileName; if (file_exists($lockFilePath)) { unlink($lockFilePath); } return parent::afterAction($action, $params, $exitCode); }
public function __construct() { $this->path = Yii::app()->params['hscic']['data']['path']; $this->tempPath = Yii::app()->params['hscic']['data']['temp_path']; if (!file_exists($this->path)) { mkdir($this->path, 0777, true); } if (!file_exists($this->tempPath)) { mkdir($this->tempPath, 0777, true); } $this->files = $this->mapFileConfig(static::$file_config); parent::__construct(null, null); }
/** * Ini system param */ public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); $this->_synchronization = new Synchronization(); $this->_logger = LoggerFactory::getFileLogger('TcpClientCommand'); // $this->_logger = LoggerFactory::getConsoleLogger(); if (Synchronization::setTcpClientPid(getmypid())) { $this->_logger->log(__METHOD__ . ' ' . 'process can take pid = ' . getmypid()); } else { $this->_logger->log(__METHOD__ . ' ' . 'process can not take pid.'); } }
/** * Converts unnamed arguments to named. * Uses current action params as names. */ public function run($args) { list($action, $options, $args) = $this->resolveRequest($args); $methodName = 'action' . $action; if (!preg_match('/^\\w+$/', $action) || !method_exists($this, $methodName)) { $this->usageError("Unknown action: " . $action); } $method = new ReflectionMethod($this, $methodName); foreach ($method->getParameters() as $i => $param) { if (!empty($args)) { $options[$param->getName()] = array_shift($args); } } $args2 = array($action); foreach ($options as $key => $value) { $args2[] = '--' . $key . ($value !== true ? '=' . $value : ''); } $args2 = array_merge($args2, $args); return parent::run($args2); }
/** * Deciding if we are running the command locally or on Iron Workers * @see CConsoleCommand::run() * @param $args array * @return If run locally the exit code. If run as IronWorker the ironWorker id. */ public function run($args) { //Store the parameters passed to the function, will be used to pass on to the iron workers $this->yiicParams = $args; //Add in the command name array_unshift($this->yiicParams, $this->getName()); //Add in the entry script name array_unshift($this->yiicParams, "./" . $this->getCommandRunner()->getScriptName()); CVarDumper::dump($this->yiicParams, 100, false); if ($this->isIronWorker()) { $this->ironWorker = true; //Kick the command off to Iron Workers $resId = $this->runAsIronWorker(); echo "Task " . $resId . " pushed to Iron Worker!\n"; //When run as an iron worker we return the IronWorker id return $resId; } else { parent::run($args); } }
/** * Initialize empty config parameters. */ public function init() { parent::init(); //Checking PHP interpriter path if ($this->interpreterPath === null) { if ($this->isWindowsOS()) { //Windows OS $this->interpreterPath = 'php.exe'; } else { //nix based OS $this->interpreterPath = '/usr/bin/env php'; } } //Checking logs directory if ($this->logsDir === null) { $this->logsDir = Yii::app()->getRuntimePath(); } //Checking bootstrap script if ($this->bootstrapScript === null) { $this->bootstrapScript = realpath($this->getCommandRunner()->getScriptName()); } }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); error_reporting(E_ALL & ~E_WARNING); date_default_timezone_set('UTC'); /** * For flexibility system */ $this->founded_in = date('YmdHis'); /** * Logger */ $this->logger = LoggerFactory::getFileLogger('SyncStatusCommand'); // $this->logger = LoggerFactory::getConsoleLogger(); /** * Settings */ $this->settings = new Synchronization(); /** * Check pid */ if ($this->settings->getSynsStatusCommandPid() && ProcessPid::isActiveProcess($this->settings->getSynsStatusCommandPid())) { exit; } else { $this->settings->setSynsStatusCommandPid(getmypid()); } /** * Connector */ $server = ['ip' => $this->settings->server_ip, 'port' => $this->settings->server_port]; $client = ['ip' => $this->settings->remote_server_ip, 'port' => $this->settings->remote_server_port]; $this->connector = new UDPConnector($this->logger, $server, $client); /** * Message */ $this->message_features = [SyncStatusHandler::MESSAGE_TYPE => 'S', SyncStatusHandler::MESSAGE_FROM => $this->settings->getIdentificator(), SyncStatusHandler::FOUNDED_IN => $this->founded_in]; }
public function __construct($name, $runner) { //non conflicting alias $alias = md5(__DIR__); Yii::setPathOfAlias($alias, __DIR__); //configuring $configPath = Yii::getPathOfAlias($alias . '.configs'); $config = new CConfiguration(array('alias' => $alias)); $config->loadFromFile($configPath . '/stdConfig.php'); //base config if ($this->config) { $config->loadFromFile($configPath . '/' . $this->config . '.php'); } foreach ($config as $key => $val) { $this->{$key} = $val; } //do import Yii::import($alias . '.*', true); Yii::import($alias . '.iterators.*', true); //set translaitor Yii::app()->setComponent('docBlockMessage', Yii::createComponent($this->messageSource)); parent::__construct($name, $runner); }
/** * Provides the command description. * @return string the command description. */ public function getHelp() { return parent::getHelp() . ' [command-name]'; }
public function confirm($message, $default = false) { if (!$this->interactive) { return true; } return parent::confirm($message, $default); }
public function beforeAction($action, $params) { $path = Yii::getPathOfAlias($this->migrationPath); if ($path === false || !is_dir($path)) { echo 'Error: The migration directory does not exist: ' . $this->migrationPath . "\n"; exit(1); } $this->migrationPath = $path; $yiiVersion = Yii::getVersion(); echo "\nYii Migration Tool for MongoYii v1.0 (based on Yii v{$yiiVersion})\n\n"; return CConsoleCommand::beforeAction($action, $params); }
public function getHelp() { $description = "DESCRIPTION\n"; $description .= ' ' . "This command generates an initial Projects/Issues RBAC authorization hierarchy.\n"; return parent::getHelp() . $description; }