diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-08-04 21:53:50 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-08-20 15:24:10 +0200 |
commit | c164409ee7f921a96f95e1fe95d86fe07a98963e (patch) | |
tree | 42fc9ded3b31d152242258518366da0c145b570d /lib/private/Console | |
parent | 1d2bc9c45ecbbb7521dbf14dba6560d925691f01 (diff) | |
download | nextcloud-server-c164409ee7f921a96f95e1fe95d86fe07a98963e.tar.gz nextcloud-server-c164409ee7f921a96f95e1fe95d86fe07a98963e.zip |
Adds a memory limit warning for console commands if the limit is below the recommended value
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'lib/private/Console')
-rw-r--r-- | lib/private/Console/Application.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 1de5fbd6ca3..422e78ee06f 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -29,6 +29,7 @@ */ namespace OC\Console; +use OC\MemoryInfo; use OC\NeedsUpdateException; use OC_App; use OCP\AppFramework\QueryException; @@ -52,20 +53,28 @@ class Application { private $request; /** @var ILogger */ private $logger; + /** @var MemoryInfo */ + private $memoryInfo; /** * @param IConfig $config * @param EventDispatcherInterface $dispatcher * @param IRequest $request * @param ILogger $logger + * @param MemoryInfo $memoryInfo */ - public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request, ILogger $logger) { + public function __construct(IConfig $config, + EventDispatcherInterface $dispatcher, + IRequest $request, + ILogger $logger, + MemoryInfo $memoryInfo) { $defaults = \OC::$server->getThemingDefaults(); $this->config = $config; $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString()); $this->dispatcher = $dispatcher; $this->request = $request; $this->logger = $logger; + $this->memoryInfo = $memoryInfo; } /** @@ -97,6 +106,11 @@ class Application { if ($input->getOption('no-warnings')) { $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); } + + if ($this->memoryInfo->isMemoryLimitSufficient() === false) { + $this->writeMemoryLimitInfo($output); + } + try { require_once __DIR__ . '/../../../core/register_command.php'; if ($this->config->getSystemValue('installed', false)) { @@ -174,6 +188,20 @@ class Application { } /** + * Write a memory info output if the limit is below the recommended value. + * + * @param ConsoleOutputInterface $output + * @return void + */ + private function writeMemoryLimitInfo(ConsoleOutputInterface $output) { + $errOutput = $output->getErrorOutput(); + $errOutput->writeln( + '<comment>The current PHP memory limit ' . + 'is below the recommended value of 512MB.</comment>' + ); + } + + /** * Sets whether to automatically exit after a command execution or not. * * @param bool $boolean Whether to automatically exit after a command execution or not |