Skip to content

Commit 18b37d3

Browse files
committed
Add step to update cache host for sites
1 parent 44d5ffc commit 18b37d3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

migrations/container/20181225063950_service-command_change_global_service_container_names.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,24 @@ public function up() {
3232
}
3333

3434
EE::debug( 'Starting change-global-service-container-name' );
35-
3635
self::$rsp = new EE\RevertableStepProcessor();
36+
37+
/**
38+
* Sites wp-config changes for global-cache.
39+
*/
40+
$cache_sites = EE\Model\Site::find( 'global-redis', 'cache_host' );
41+
foreach ( $cache_sites as $site ) {
42+
43+
self::$rsp->add_step(
44+
sprintf( 'update-cache-host-%s', $site->site_url ),
45+
'EE\Migration\SiteContainers::backup_restore',
46+
null,
47+
[ $site ],
48+
null
49+
);
50+
51+
}
52+
3753
$global_compose_file_path = EE_ROOT_DIR . '/services/docker-compose.yml';
3854
$global_compose_file_backup_path = EE_BACKUP_DIR . '/services/docker-compose.yml.backup';
3955

@@ -184,5 +200,23 @@ public static function start_global_service_containers( $containers ) {
184200

185201
}
186202

203+
/**
204+
* Update redis cache host name.
205+
*
206+
* @param $site_info EE\Model\Site site information.
207+
*
208+
* @throws \Exception
209+
*/
210+
public static function update_cache_host( $site_info ) {
211+
$update_hostname_constant = "docker-compose exec --user='www-data' php wp config set RT_WP_NGINX_HELPER_REDIS_HOSTNAME global-redis --add=true --type=constant";
212+
213+
if( ! chdir( $site_info->site_fs_path ) ) {
214+
throw new \Exception( sprintf( '%s path not exists', $site_info->site_fs_path ) );
215+
}
216+
217+
if ( ! EE::exec( $update_hostname_constant ) ) {
218+
throw new \Exception( sprintf( 'Unable to update cache host of %s', $site_info->site_url ) );
219+
}
220+
}
187221

188222
}

0 commit comments

Comments
 (0)