1

When trying to run even simple command like:

php bin/magento cache:clean

It just stucks. Though some of the command like

php bin/magento cache:disable
php bin/magento cache:enable
php bin/magento index:reindex

do run. but for the commands, which stucks, when I see the server load keeps increasing to staggering number like form 1% it goes up to 35%

I am not able to find out where is the issue. in the same installation, I was able to run these commands.

update:if I run the command with memory_limit=-1 the script never seems to end, but if I limit it like `memory_limit=10G' I get this error

Running schema recurring...PHP Fatal error: Allowed memory size of 10737418240 bytes exhausted (tried to allocate 20480 bytes) in /web/vendor/magento/framework/App/State.php on line 152

the relevant code on line 152 reads like this:

 /**
     * Get area code
     *
     * @return string
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getAreaCode()
    {
        if (!isset($this->_areaCode)) {
            throw new \Magento\Framework\Exception\LocalizedException(
                new \Magento\Framework\Phrase('Area code is not set')
            );
        }
        return $this->_areaCode;
    }

and the module which seems responsible for the error, the code looks like this:

class AppState
{
/**
 * @var \Magento\Framework\App\State
 */
protected $state;

/**
 * @param \Magento\Framework\App\State $state
 */
public function __construct(\Magento\Framework\App\State $state) {
    $this->state = $state;
}

/**
 * @return bool
 */
public function isFrontendArea()
{
    try {
        if ($this->state->getAreaCode() == Area::AREA_ADMINHTML) {
            return false;
        }
    } catch (LocalizedException $e) {
        /* Area is not initialized. Do nothing. */
        return true;
    }
    return true;
}

}

I think this info is enough for any expert to find the issue I am facing.

Thanks.

1 Answer 1

2

It may be lack of available memory.

Many of the magento2 cli commands incur heavy cpu and memory usage. The reindexing in particular is a heavy duty process.

Try running the cli commands with unlimited memory.

php -d memory_limit=-1 bin/magento indexer:reindex

If even that stalls it means you need to allocate more memory to your vm.

In my local devbox I have 2 GB allocated, and I have to run the cli with the "-d memory_limit=-1" option every time otherwise it freezes/crashes.

3
  • Hi - indexer:reindex command is working fine. The problem I am facing is with other commands.
    – Joshi
    Commented Jan 13, 2018 at 11:41
  • Hi still have issues. don't know why. but there is some success with your suggestion. As regarding the memory available I have 16GB as Dedicated server.
    – Joshi
    Commented Jan 13, 2018 at 19:47
  • You might be able to improve the reindexing process by indicating specific indexes, as running the command without any arguments runs all indexers. Commented Jan 25, 2018 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.