Comments (8)
@valguss Hope you have any suggestions how we could resolve this.
from deployer.
For the moment i'd suggest disabling using the cache_prefixes
Is there a way for you to sync up the releases, so they are the same number?
from deployer.
@valguss, yes, I can get the release in sync quite easily. However I'm stuck with the first / "alias" part of the key.
from deployer.
You could override the task in your deployer.php
with something like the following (not ideal I know):
desc('Update cache id_prefix');
task('magento:set_cache_prefix', function () {
//download current env config
$tmpConfigFile = tempnam(sys_get_temp_dir(), 'deployer_config');
download('{{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH, $tmpConfigFile);
$envConfigArray = include($tmpConfigFile);
//set prefix to `alias_releasename_`
$prefixUpdate = 'abc_' . get('release_name') . '_';
//check for preload keys and update
if (isset($envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys'])) {
$oldPrefix = $envConfigArray['cache']['frontend']['default']['id_prefix'];
$preloadKeys = $envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys'];
$newPreloadKeys = [];
foreach ($preloadKeys as $preloadKey) {
$newPreloadKeys[] = preg_replace('/^' . $oldPrefix . '/', $prefixUpdate, $preloadKey);
}
$envConfigArray['cache']['frontend']['default']['backend_options']['preload_keys'] = $newPreloadKeys;
}
//update id_prefix to include release name
$envConfigArray['cache']['frontend']['default']['id_prefix'] = $prefixUpdate;
$envConfigArray['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate;
//Generate configuration array as string
$envConfigStr = '<?php return ' . var_export($envConfigArray, true) . ';';
file_put_contents($tmpConfigFile, $envConfigStr);
//upload updated config to server
upload($tmpConfigFile, '{{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH);
//cleanup tmp file
unlink($tmpConfigFile);
//delete the symlink for env.php
run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH);
//link the env to the tmp version
run('{{bin/symlink}} {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH);
});
I've just updated
$prefixUpdate = get('alias') . '_' . get('release_name') . '_';
to
$prefixUpdate = 'abc_' . get('release_name') . '_';
from deployer.
@valguss, thanks. We can do a workaround but would like to see this fixed in the official recipe as well and would like to contribute to a solution.
Best practice is to have the same redis DB per environment. So in theory we could drop the "get('alias')" part of the prefix all together. Or we could use the "stage" of the host, so that the first part of the prefix is the same for all hosts in that stage. Can you just do get('stage') in order to get the host stage?
from deployer.
Using stage sounds like a better solution. The premise I was going for was for our specific setup where staging sites sit on the same server as the live env, so was trying to make the key unique to each environment so that they didn't clash. Will get a PR up shortly to change it though.
Thanks
from deployer.
Using stage sounds like a better solution. The premise I was going for was for our specific setup where staging sites sit on the same server as the live env, so was trying to make the key unique to each environment so that they didn't clash. Will get a PR up shortly to change it though.
Thanks
Stage sounds good to me. I get your use case and with using "stage" this still works. I do think it's better to use a different Redis database number for a test environment and a live environment when they are both on the same server. Something like this:
'page_cache' => [
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => '127.0.0.1',
'port' => '6379',
'database' => '1', ## HAVE A DIFFERENT DB NUMBER HERE FOR TEST OR PRODUCTION ENVIRONMENTS
'compress_data' => '0'
]
]
from deployer.
Now updated to check if stage is available and fall back to alias
from deployer.
Related Issues (20)
- Deployer ignores given repository url
- Setup task randomly fails HOT 2
- Shopware recipe HOT 5
- Magento 2 Recipe: Use roles to execute DB tasks only on one server HOT 8
- contrib/rsync set('rsync_src', __DIR__); returns phar:///.../contrib/ HOT 2
- Git Error During Deployment HOT 4
- Restart from failed step HOT 3
- Incompatible declaration when using AWS SDK in deploy.php HOT 6
- Disabling parent group task will not disable all child tasks
- Shopware recipe always updates all plugins HOT 2
- manifest.json deprication HOT 3
- Provision: file_get_contents(./Caddyfile): Failed to open stream: No such file or directory
- Hardlinks out of the box
- Add Nuxt JS deploy recipe HOT 2
- Source code SSH settings from local .ssh/config
- Deploy all hosts asynchronously rather than synchronously HOT 6
- automatic docs generation places Shopware docs link into all recipe docs
- `bin/docgen` expands curly braces, even if they are marked as code HOT 1
- Bugs related to provision:website
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 deployer.