Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain old format of mariadb config #64

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function up() {
* Sites wp-config changes for global-cache.
*/
$cache_sites = EE::db()
->table( 'sites' )
->where( [ [ 'site_type', '==', 'wp' ], [ 'cache_host', '==', 'global-redis' ] ] )
->all();
->table( 'sites' )
->where( [ [ 'site_type', '==', 'wp' ], [ 'cache_host', '==', 'global-redis' ] ] )
->all();

foreach ( $cache_sites as $site ) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace EE\Migration;

use EE;
use \Symfony\Component\Filesystem\Filesystem;
use function EE\Utils\trailingslashit;

class ConfigureMyCNF extends Base {

/** @var RevertableStepProcessor $rsp Keeps track of migration state. Reverts on error */
private static $rsp;

public function __construct() {

parent::__construct();
if ( $this->is_first_execution ) {
$this->skip_this_migration = true;
}
}

/**
* Execute global service container name update.
*
* @throws EE\ExitException
*/
public function up() {

if ( $this->skip_this_migration ) {
EE::debug( 'Skipping configure-my-cnf migration as it is not needed.' );

return;
}

EE::debug( 'Starting configure-my-cnf' );

$my_cnf = EE_SERVICE_DIR . '/mariadb/conf/my.cnf';

if ( is_link( $my_cnf ) ) {
unlink( trailingslashit( dirname( $my_cnf ) ) . readlink( $my_cnf ) );
unlink( $my_cnf );

EE::exec( 'rm -f ' . EE_SERVICE_DIR . '/mariadb/conf/mariadb.conf.d/*.cnf' );

$fs = new Filesystem();
$fs->copy( SERVICE_TEMPLATE_ROOT . '/my.cnf.mustache', $my_cnf );

EE::exec( 'cd ' . EE_SERVICE_DIR . ' && docker-compose restart global-db' );
}
}

/**
* No need for down.
*
* @throws EE\ExitException
*/
public function down() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function up() {
$running_services[ $count ]['name'] = $service;
$launch = EE::launch( 'docker-compose ps -q global-' . $service );
$running_services[ $count ]['state'] = $launch->stdout;
$count++;
$count ++;
}

\EE\Service\Utils\generate_global_docker_compose_yml( $this->fs );
Expand Down
2 changes: 1 addition & 1 deletion src/Service_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function refresh( $args, $assoc_args ) {
$running_services[ $count ]['name'] = $service;
$launch = EE::launch( 'docker-compose ps -q global-' . $service );
$running_services[ $count ]['state'] = $launch->stdout;
$count++;
$count ++;
}

\EE\Service\Utils\generate_global_docker_compose_yml( new Symfony\Component\Filesystem\Filesystem() );
Expand Down
1 change: 1 addition & 0 deletions src/helper/service-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function init_global_container( $service, $container = '' ) {
$fs->copy( SERVICE_TEMPLATE_ROOT . '/my.cnf.mustache', $db_conf_file );
}
\EE_DOCKER::boot_container( $container, \EE_DOCKER::docker_compose_with_custom() . ' up -d ' . $service );

return true;
} else {
return false;
Expand Down
Loading