Comments (6)
That's not possible, but I should make sure that running commands between release_path and current_path the cache should be flushed.
from capistrano-magento2.
We have also experienced this. But we have seen that capistrano-magento2
in the end just invokes magento:setup:di:compile
, so it didn't look like the element to blame:
We still have some issues in our production environment during production releases - where classes are not generated.
But seeing your issue @PascalBrouwers made us thought of it to tackle it better than manually copying the generated
files from the staging server to production 😅
Maybe capistrano-magento2
could force Magento to ignore the Redis cache while preparing the 2nd release?
from capistrano-magento2.
Small update: you also need to fix the autoloader because that is cached too. So run this too:
invoke!('magento:composer:install') if fetch(:magento_deploy_composer)
from capistrano-magento2.
Trying to get a fail-safe method for this but it feels like there isn't one.
As soon as you flush the redis cache there is the possibility that a visitor is on the site and trigger the redis cache for the current release, while you were trying to fill it with the release_path.
There is the option to set the maintenance flag, but that would mean a long downtime.
from capistrano-magento2.
Also an issue when running php 7.2 / 7.3 in your current release and the latest release need php 7.4
Running composer install in both directories isn't going to work with the same php version.
from capistrano-magento2.
Decided to go with using a different cache prefix for each deployment. This way generated files and other caches don't interfere with each other during a deploy for a site that has allot of visitors. Because this runs before composer, if also fixes the issue with the classmap cache.
after "deploy:symlink:linked_files", "set_cache_prefix"
task :set_cache_prefix do
on release_roles :all do
within release_path do
unless test %Q[#{SSHKit.config.command_map[:php]} -r '
$cfg = include "#{shared_path}/app/etc/env.php";
exit((int)!isset($cfg["cache"]["frontend"]["default"]["id_prefix"]));
']
# generate a new prefix
version = '100_'
else
# get the current prefix
version = capture %Q[#{SSHKit.config.command_map[:php]} -r '
$cfg = include "#{shared_path}/app/etc/env.php";
echo(($cfg["cache"]["frontend"]["default"]["id_prefix"]));
']
end
# convert prefix to a number and increment it
version = version.gsub("_", "")
versionNumber = version.to_i
newVersionNumber = versionNumber + 1
set :newVersionNumber, newVersionNumber
# copy the file as a normal file in the next release
execute :rm, "-rf #{release_path}/app/etc/env.php"
execute :cp, "-rf #{shared_path}/app/etc/env.php #{release_path}/app/etc/env.php"
execute %Q[#{SSHKit.config.command_map[:php]} -r '
$cfg = include "#{release_path}/app/etc/env.php";
$cfg["cache"]["frontend"]["default"]["id_prefix"] = "#{fetch(:newVersionNumber)}_";
$out = "<?php return " . var_export($cfg, true) . ";"
file_put_contents("#{release_path}/app/etc/env.php", $out);
']
# save new env file to shared dir
execute :rm, "-rf #{shared_path}/app/etc/env.php"
execute :cp, "-rf #{release_path}/app/etc/env.php #{shared_path}/app/etc/env.php"
end
end
end
Works when env.php does not have a cache prefix yet. Also Magento fixes the array(
syntax with a short syntax [
during deployment by itself.
@davidalger is this an idea to include it?
from capistrano-magento2.
Related Issues (20)
- Do not run show pending updates when capistrano is outside magento git repo HOT 1
- var/reports HOT 2
- Can't install 'capistrano/magento2/cachetool' HOT 2
- [enhancement] Deploy on multiple fronts without recompiling everything on each machine HOT 2
- Catalog product images in production mode delete after deploy HOT 1
- Change default path of Composer HOT 2
- Magento still has issues with /pub in sitemap HOT 1
- Change deployment order of DI compile and schema upgrade HOT 2
- Problem with deploy after updated module with SFTP error in setup:di:compile step HOT 5
- Doesn't work with PHP 7.4 and Magento 2..42 HOT 4
- When execute command cap staging deploy
- Issue: Cached metadata/generated files HOT 7
- How to handle initial setup:install HOT 1
- How can I flush cache file on multi server HOT 1
- touch: cannot touch '/var/www/html/releases/20220809134142/pub/static/deployed_version.txt' No such file or directory HOT 1
- Suggestion: Add arbitrary composer_flags or option to run composer with --no-plugins HOT 1
- Capistrano version
- Support for Quality Patches Tool
- When upgrading PHP version, mainenance:enable runs against old codebase, using new php version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capistrano-magento2.