yum
upgrades for production use, this is the repository for you.
Active subscription is required.
Earlier we described how you can reduce Magento 2 “deployment downtime” by using CircleCI workflow.
If you’re feeling a little less serious and lazy to implement all those moving parts, here’s a same-server workflow for you.
It’s also useful for development.
Often times, you have a complete/easy-to-restore-backup of your website, and you just want to composer update
something and there you go, you have bear with inevitable downtime
having to deploy the static assets. How to eliminate it? Without using git or fancy CI integrations.
Simple: create the “shadow” directory on the same server.
What is a shadow directory?
It is a directory that holds a copy of your live Magento 2 website, on the same (live) server.
You can exclude irrelevant data files from it. For example, having pub/media
in the shadow directory is not needed.
If your live M2 files are in /srv/www/example.com
and are web accessible, the shadow directory, should live somewhere not web-accessible.
For example, the home directory of the Magento user: ~/shadow/example.com
.
Making use of the shadow directory
Whenever we want to composer update
production site, the downtime can be tremendously reduced by running the relevant steps in shadow directory.
Steps for composer update
would be:
- sync live files to shadow directory, excluding all directories/files which are not needed for generating code / deploying assets
composer update
in the shadow directorydi:compile
and deploy static assets in the shadow directory- copy generated files to live directory
- run
bin/magento setup:upgrade --keep-generated
at live directory - flush all caches or only those affected, e.g. clear PHP opcache for recently modified files only
With the GetPageSpeed n98-magerun2 commands you can reduce shadow compilation by faster static files processing:
THEMES=$(n98-magerun2 dev:theme:active)
LOCALES=$(n98-magerun2 deploy:locale:active)
php ./bin/magento setup:static-content:deploy --jobs=$(nproc) ${THEMES} ${LOCALES}
This regenerates static assets only for the active themes and locales.
To simplify the above workflow, you can instead use the clearmage2
CLI utility, which leverages the shadow directory principle and saves you a lot of time and trouble when upgrading Magento 2 or installing/enabling/disabling its modules!
The clearmage2
utility is only available by subscription to our RPM repository.