Let's start with the little mind-reading magic trick.
1. Do you use Magento 2?
- Yes, you definitely do.
2. Do you hate to see when your store is broken while running Magento 2 deployment commands?
- Yes, you do.
Did we guess?
Yes? That's great. In the next 5 minutes we will help you with this pain. At Magefan we have created bash Linux script that allows you to run bin/magento setup commands without braking store, long downtime and losing sales.
Alert, sudo, echo. The article includes technical information, you can forward it to your developers or contact us if you'll need any help.
To install Magento 2 zero-downtime deployment script run these CLI commands in the Magento root directory:
wget -O deploy.zip https://github.com/magefan/magento2-zero-downtime-deploy/archive/master.zip
rm -f deploy.zip
mv magento2-zero-downtime-deploy-master/ deploy
cp deploy/app/static-content-deploy.sh.sample deploy/app/static-content-deploy.sh
cp app/etc/env.php deploy/app/env.php
echo $'\n'deploy/app/env.php >> .gitignore chmod +x deploy/run
1. If you use specific static-content deploy commands then edit the file
By default, it has commands to deploy all Magento 2 themes in en_US locale.
2. If you use Redis or other non-folder storage for session or cache, then edit file
Make sure that cache and session are stored to a folder.
1. To deploy Magento static content (bin/magento setup:static-content:deploy) with NO downtime, use the CLI command:
2. To generated code and dependency injection configuration (bin/magento setup:di:compile) with NO downtime, use the CLI command:
You can also run the script with multiple parameters, e.g:
deploy/run -d -s
3. To update modules database data and schema (bin/magento setup:upgrade), use the CLI command:
If you install new extensions then run this command:
deploy/run -m Vendor_Module1 Vendor_Module2
Note that these commands will also run DI and static content generation and this is the only command that put Magento 2 store into maintenance mode for a few seconds while setup:upgrade is running.
Does it really work?
- Yes, it does. We already use it at magefan.com and in a few clients stores to deploy new design and business logic changes. We're happy to share it with you.