protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption("maintenance-mode")) { // set the timeout between each iteration to 0 if maintenance mode is on, because // we don't have to care about the load on the server Warming::setTimoutBetweenIteration(0); } try { $types = $this->getArrayOption('types', 'validTypes', 'type', true); $documentTypes = $this->getArrayOption('documentTypes', 'validDocumentTypes', 'document type'); $assetTypes = $this->getArrayOption('assetTypes', 'validAssetTypes', 'asset type'); $objectTypes = $this->getArrayOption('objectTypes', 'validObjectTypes', 'object type'); } catch (\InvalidArgumentException $e) { $this->writeError($e->getMessage()); return 1; } if (in_array('document', $types)) { $this->writeWarmingMessage('document', $documentTypes); Warming::documents($documentTypes); } if (in_array('asset', $types)) { $this->writeWarmingMessage('asset', $assetTypes); Warming::assets($assetTypes); } if (in_array('object', $types)) { $this->writeWarmingMessage('object', $objectTypes); Warming::assets($assetTypes); } $this->disableMaintenanceMode(); }
/** * Enable maintenance mode if --maintenanceMode option was passed */ protected function enableMaintenanceMode() { // enable maintenance mode if requested if ($this->input->getOption('maintenanceMode')) { $maintenanceModeId = 'cache-warming-dummy-session-id'; $this->output->writeln('Activating maintenance mode with ID <comment>%s</comment>...', $maintenanceModeId); Admin::activateMaintenanceMode($maintenanceModeId); // set the timeout between each iteration to 0 if maintenance mode is on, because // we don't have to care about the load on the server Warming::setTimoutBetweenIteration(0); } }
use Pimcore\Cache\Tool\Warming as Warmer; try { $opts = new \Zend_Console_Getopt(array('types|t=s' => 'perform warming only for this types of elements (comma separated), valid arguments: document,asset,object (default: all types)', "documentTypes|dt=s" => "only for these types of documents (comma separated), valid arguments: page,snippet,folder,link (default: all types)", "assetTypes|at=s" => "only for these types of assets (comma separated), valid arguments: folder,image,text,audio,video,document,archive,unknown (default: all types)", "objectTypes|ot=s" => "only for these types of objects (comma separated), valid arguments: object,folder,variant (default: all types)", "classes|c=s" => "this is only for objects! filter by class (comma separated), valid arguments: class-names of your classes defined in pimcore", "maintenanceMode|m" => "enable maintenance mode during cache warming", 'verbose|v' => 'show detailed information during the maintenance (for debug, ...)', 'help|h' => 'display this help')); } catch (Exception $e) { echo $e->getMessage(); } // display help message if ($opts->getOption("help")) { echo $opts->getUsageMessage(); exit; } // enable maintenance mode if requested if ($opts->getOption("maintenanceMode")) { \Pimcore\Tool\Admin::activateMaintenanceMode("cache-warming-dummy-session-id"); // set the timeout between each iteration to 0 if maintenance mode is on, because we don't have to care about the load on the server Warmer::setTimoutBetweenIteration(0); } if ($opts->getOption("verbose")) { $writer = new \Zend_Log_Writer_Stream('php://output'); $logger = new \Zend_Log($writer); \Logger::addLogger($logger); // set all priorities \Logger::setVerbosePriorities(); } // get valid types (default all types) $types = array("document", "asset", "object"); if ($opts->getOption("types")) { $types = explode(",", $opts->getOption("types")); } if (in_array("document", $types)) { $docTypes = null;