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

Fix code structure #39

Open
wants to merge 2 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 @@ -7,6 +7,7 @@
use EE\Migration\SiteContainers;
use EE\RevertableStepProcessor;
use EE\Model\Site;
use EE\Utils as EE_Utils;

class AddNewEeConfForDb extends Base {

Expand Down Expand Up @@ -57,7 +58,7 @@ public function up() {
'timeout' => 600, // 10 minutes ought to be enough for everybody.
'filename' => $backup_ee_conf,
];
\EE\Utils\http_request( 'GET', $download_url, null, $headers, $options );
EE_Utils\http_request( 'GET', $download_url, null, $headers, $options );

self::$rsp->add_step(
'add-new-ee-conf-to-global-db',
Expand Down
5 changes: 3 additions & 2 deletions src/Service_Command.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Symfony\Component\Filesystem\Filesystem;
use EE\Service\Utils as Service_Utils;

/**
* Manages global services of EasyEngine.
Expand Down Expand Up @@ -56,9 +57,9 @@ public function enable( $args, $assoc_args ) {
$container = "ee-$service";

if ( EE_PROXY_TYPE === $container ) {
\EE\Service\Utils\nginx_proxy_check();
Service_Utils\nginx_proxy_check();
} else {
\EE\Service\Utils\init_global_container( $service );
Service_Utils\init_global_container( $service );
}

}
Expand Down
19 changes: 10 additions & 9 deletions src/helper/service-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use EE;
use Symfony\Component\Filesystem\Filesystem;
use EE\Utils as EE_Utils;

/**
* Boots up the container if it is stopped or not running.
Expand All @@ -13,8 +14,8 @@ function nginx_proxy_check() {

$proxy_type = EE_PROXY_TYPE;

$config_80_port = \EE\Utils\get_config_value( 'proxy_80_port', '80' );
$config_443_port = \EE\Utils\get_config_value( 'proxy_443_port', '443' );
$config_80_port = EE_Utils\get_config_value( 'proxy_80_port', '80' );
$config_443_port = EE_Utils\get_config_value( 'proxy_443_port', '443' );

if ( 'running' === \EE_DOCKER::container_status( $proxy_type ) ) {
$launch_80_test = EE::launch( 'docker inspect --format \'{{ (index (index .NetworkSettings.Ports "80/tcp") 0).HostPort }}\' ee-global-nginx-proxy' );
Expand All @@ -30,8 +31,8 @@ function nginx_proxy_check() {
/**
* Checking ports.
*/
$port_80_status = \EE\Utils\get_curl_info( 'localhost', $config_80_port, true );
$port_443_status = \EE\Utils\get_curl_info( 'localhost', $config_443_port, true );
$port_80_status = EE_Utils\get_curl_info( 'localhost', $config_80_port, true );
$port_443_status = EE_Utils\get_curl_info( 'localhost', $config_443_port, true );

// if any/both the port/s is/are occupied.
if ( ! ( $port_80_status && $port_443_status ) ) {
Expand Down Expand Up @@ -110,9 +111,9 @@ function boot_global_networks() {
*/
function generate_global_docker_compose_yml( Filesystem $fs ) {

$img_versions = EE\Utils\get_image_versions();
$config_80_port = \EE\Utils\get_config_value( 'proxy_80_port', 80 );
$config_443_port = \EE\Utils\get_config_value( 'proxy_443_port', 443 );
$img_versions = EE_Utils\get_image_versions();
$config_80_port = EE_Utils\get_config_value( 'proxy_80_port', 80 );
$config_443_port = EE_Utils\get_config_value( 'proxy_443_port', 443 );

$fs = new Filesystem();
$backup_yml = EE_BACKUP_DIR . '/services/docker-compose.yml.backup';
Expand All @@ -121,7 +122,7 @@ function generate_global_docker_compose_yml( Filesystem $fs ) {
$launch = EE::launch( sprintf( 'cat %s | grep MYSQL_ROOT_PASSWORD | cut -d"=" -f2', $backup_yml ) );
$password = trim( $launch->stdout );
}
$password = empty( $password ) ? \EE\Utils\random_password() : $password;
$password = empty( $password ) ? EE_Utils\random_password() : $password;

$volumes_nginx_proxy = [
[
Expand Down Expand Up @@ -295,7 +296,7 @@ function generate_global_docker_compose_yml( Filesystem $fs ) {
],
];

$contents = EE\Utils\mustache_render( SERVICE_TEMPLATE_ROOT . '/global_docker_compose.yml.mustache', $data );
$contents = EE_Utils\mustache_render( SERVICE_TEMPLATE_ROOT . '/global_docker_compose.yml.mustache', $data );
$fs->dumpFile( EE_SERVICE_DIR . '/docker-compose.yml', $contents );
}

Expand Down