Skip to content

Commit 3548fc4

Browse files
committed
Add service command
1 parent 6508ac5 commit 3548fc4

File tree

8 files changed

+160
-1
lines changed

8 files changed

+160
-1
lines changed

.distignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
.git
3+
.gitignore
4+
.gitlab-ci.yml
5+
.editorconfig
6+
.travis.yml
7+
behat.yml
8+
circle.yml
9+
bin/
10+
features/
11+
utils/
12+
*.zip
13+
*.tar.gz
14+
*.swp
15+
*.txt
16+
*.log

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
# WordPress Coding Standards
5+
# https://make.wordpress.org/core/handbook/coding-standards/
6+
7+
root = true
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
insert_final_newline = true
13+
trim_trailing_whitespace = true
14+
indent_style = tab
15+
16+
[{.jshintrc,*.json,*.yml,*.feature}]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[{*.txt,wp-config-sample.php}]
21+
end_of_line = crlf
22+
23+
[composer.json]
24+
indent_style = space
25+
indent_size = 4

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.DS_Store
2+
ee.local.yml
3+
node_modules/
4+
vendor/
5+
*.zip
6+
*.tar.gz
7+
*.swp
8+
*.txt
9+
*.log
10+
composer.lock
11+
.idea
12+
*.db

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# service-command
1+
# EasyEngine/service-command
2+
3+
Manages global `ee-nginx-proxy` container.
4+
5+
## About `ee-nginx-proxy`
6+
`ee-nginx-proxy` is the main container which routes all incoming request to site-specific containers.
7+
8+
So let's say you have foo.com and bar.com on same ee server. When anyone requests either website, the request will first go to `ee-nginx-proxy` which will forward the request to appropriate nginx container of site (In this case foo.com or bar.com).
9+
10+
## Usage:
11+
12+
```
13+
ee service start # starts global container
14+
ee service restart # restarts global container
15+
ee service stop # stops global container
16+
ee service reload # reloads global container
17+
```
18+
19+
For more info run ee service --help

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "easyengine/service-command",
3+
"description": "Shell to run helpful commands inside containers.",
4+
"type": "ee-cli-package",
5+
"homepage": "https://github.com/easyengine/service-command",
6+
"license": "MIT",
7+
"authors": [],
8+
"minimum-stability": "dev",
9+
"prefer-stable": true,
10+
"autoload": {
11+
"psr-4": {
12+
"": "src/"
13+
},
14+
"files": [ "service-command.php" ]
15+
},
16+
"extra": {
17+
"branch-alias": {
18+
"dev-master": "1.x-dev"
19+
},
20+
"bundled": true,
21+
"commands": [
22+
"service start",
23+
"service stop",
24+
"service restart",
25+
"service reload"
26+
]
27+
}
28+
}

ee.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
- site-command.php

service-command.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
if ( ! class_exists( 'EE' ) ) {
4+
return;
5+
}
6+
7+
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8+
if ( file_exists( $autoload ) ) {
9+
require_once $autoload;
10+
}
11+
12+
EE::add_command( 'service', 'Service_Command' );

src/Service_Command.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* Executes wp-cli command on a site.
5+
*
6+
* ## EXAMPLES
7+
*
8+
* # Create simple WordPress site
9+
* $ ee wp test.local plugin list
10+
*
11+
* @package ee-cli
12+
*/
13+
14+
use EE\Utils;
15+
16+
class Service_Command extends EE_Command {
17+
18+
/**
19+
* Starts global reverse proxy container.
20+
*/
21+
public function start( $cmd, $descriptors = null ) {
22+
\EE\Utils\default_launch( "docker start ee-nginx-proxy" );
23+
}
24+
25+
/**
26+
* Stops global reverse proxy container.
27+
*/
28+
public function stop( $cmd, $descriptors = null ) {
29+
\EE\Utils\default_launch( "docker stop ee-nginx-proxy" );
30+
}
31+
32+
/**
33+
* Restarts global reverse proxy container.
34+
*/
35+
public function restart( $cmd, $descriptors = null ) {
36+
\EE\Utils\default_launch( "docker restart ee-nginx-proxy" );
37+
}
38+
39+
/**
40+
* Reloads global reverse proxy service without .
41+
*/
42+
public function reload( $cmd, $descriptors = null ) {
43+
\EE\Utils\default_launch( "docker exec ee-nginx-proxy sh -c 'nginx -t && service nginx reload'" );
44+
}
45+
46+
}

0 commit comments

Comments
 (0)