-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path20201103184813_service-command_remove_sysctl.php
More file actions
69 lines (54 loc) · 1.46 KB
/
20201103184813_service-command_remove_sysctl.php
File metadata and controls
69 lines (54 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace EE\Migration;
use EE;
use EE\Migration\Base;
use function EE\Service\Utils\generate_global_docker_compose_yml;
class RemoveSysctl 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 remove-sysctl migration as it is not needed.' );
return;
}
chdir( EE_SERVICE_DIR );
$whitelisted_services = [
'nginx-proxy',
'db',
'redis',
'newrelic-daemon',
];
$running_services = [];
$count = 0;
foreach ( $whitelisted_services as $service ) {
$running_services[ $count ]['name'] = $service;
$launch = EE::launch( 'docker-compose ps -q global-' . $service );
$running_services[ $count ]['state'] = $launch->stdout;
$count ++;
}
\EE\Service\Utils\generate_global_docker_compose_yml( $this->fs );
foreach ( $running_services as $service ) {
if ( ! empty( $service['state'] ) ) {
EE::exec( \EE_DOCKER::docker_compose_with_custom() . " up -d global-${service['name']}", true, true );
}
}
}
/**
* No need for down.
*
* @throws EE\ExitException
*/
public function down() {
}
}