Feature request from aoldoni, posted on GitHub Jun 17, 2015
This is to discuss the scenario where cron tasks still run in Magento, even in maintenance mode.
As per the installation guidelines, you should always activate the Magento cron in the crontab ( http://devdocs.magento.com/guides/v1.0/config-guide/cli/config-cli-subcommands-cron.html ). This means adding the
/bin/magento cron:run command to the crontab.
Suppose a situation where you are with Magento under maintenance mode for, let's say, 30 minutes with the intention to run a MySQL backup or run some heavy database data synchronisation script. After looking at the code, I noticed that the following entry points will fail to run as we are in maintenance mode (which is a good thing):
- cron.php (public web entry point).
- ...also API connections would fail as they all go through the
\Magento\Framework\App\Bootstrap::run() and the
./bin/magento cron:run would still run, as the cli cron entry point doesn't check for maintenance mode. Please note the following steps:
vagrant@mage2:/vagrant/data/magento2$ ./bin/magento maintenance:enable
Enabled maintenance mode
vagrant@mage2:/vagrant/data/magento2$ ./bin/magento cron:run
Ran jobs by schedule.
This means that, even in maintenance mode, the crontab could still be firing database operations, and, depending on the Magento cronjob scheduled to be executed (or new custom cronjobs that were created), it could potentially trigger other heavy database operations to run in parallel with the database maintenance operations already being executed.
So, if you really need to stop all operations in your application for a brief period of time (a maintenance window), you would (a) not only put Magento in maintenance mode, but would also need to (b) deactivate the cron.
My conclusion based on the above is that it would make sense for at least the
./bin/magento cron:run command to check for the maintenance flag as well. This would be safer, and possibly assure that during maintenance mode there's nothing happening in the application.
Can you guys please point out if you share this opinion?