rmdd 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rmd/cli.rb +28 -0
- data/lib/rmd/deploy_service.rb +30 -1
- data/lib/rmd/server.rb +4 -0
- data/lib/rmd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b450952394e9ced13ba04e68c784ee5fb43c6a0a
|
4
|
+
data.tar.gz: c53d8cbe6d51f234ad587ecf63192c98c1ec81e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1931d033dfc6b33bfac4c8a8e677e7ee5ee0205f2ea9ac407b2f8ad8e359b0f048366d52b085a9459123c91e79986bacc73ef02d1dc45c7e4ee772d5b25f7ba5
|
7
|
+
data.tar.gz: 079d485e9d9fc1a9f6696724708aa20f5a797d663d87ab8a59dd088f4120657703f3e043bb105b5cb036492d38f42bd288144dde9f7dda69af2c79d3323e0c4c
|
data/lib/rmd/cli.rb
CHANGED
@@ -34,5 +34,33 @@ module Rmd
|
|
34
34
|
rescue Exception => e
|
35
35
|
$stdout.puts(e.message)
|
36
36
|
end
|
37
|
+
|
38
|
+
desc 'logs', 'Logs of servers'
|
39
|
+
method_option :server, aliases: '-s', desc: 'Server name', type: :string, required: true
|
40
|
+
def logs
|
41
|
+
Cli.load_config
|
42
|
+
DeployService.logs(options[:server])
|
43
|
+
rescue Exception => e
|
44
|
+
$stdout.puts(e.message)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'nginx', 'Logs of the nginx server'
|
48
|
+
method_option :server, aliases: '-s', desc: 'Server name', type: :string, required: true
|
49
|
+
method_option :type, aliases: '-t', desc: "Type of log: #{TYPE}", type: :string, required: true
|
50
|
+
def nginx
|
51
|
+
Cli.load_config
|
52
|
+
DeployService.nginx(options[:server], options[:type])
|
53
|
+
rescue Exception => e
|
54
|
+
$stdout.puts(e.message)
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'console', 'Console of servers'
|
58
|
+
method_option :server, aliases: '-s', desc: 'Server name', type: :string, required: true
|
59
|
+
def console
|
60
|
+
Cli.load_config
|
61
|
+
DeployService.console(options[:server])
|
62
|
+
rescue Exception => e
|
63
|
+
$stdout.puts(e.message)
|
64
|
+
end
|
37
65
|
end
|
38
66
|
end
|
data/lib/rmd/deploy_service.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Rmd
|
2
2
|
NAME = 'autoclient/ringmd'
|
3
|
+
TYPE = ['access', 'error', 'realtime', 'web']
|
3
4
|
|
4
5
|
class ServerNotFound < StandardError; end
|
5
6
|
|
6
7
|
class DeployService
|
7
8
|
def self.deploy(server)
|
8
9
|
validate(server)
|
9
|
-
|
10
|
+
command = "curl -s #{url(server)}/deploy/#{token(server)}"
|
11
|
+
system_cmd(command)
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.restart(server)
|
@@ -15,12 +17,35 @@ module Rmd
|
|
15
17
|
system_cmd(command)
|
16
18
|
end
|
17
19
|
|
20
|
+
def self.logs(server)
|
21
|
+
validate(server)
|
22
|
+
command = %{echo "cd #{NAME} && DOCKER_HOST=:2375 docker-compose logs" | ssh #{master(server)} -p 2200}
|
23
|
+
system_cmd(command)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.logs(server, type)
|
27
|
+
validate(server)
|
28
|
+
validate_type(type)
|
29
|
+
command = %{echo "tailf nginx/log/#{type}" | ssh #{nginx(server)}}
|
30
|
+
system_cmd(command)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.console(server)
|
34
|
+
validate(server)
|
35
|
+
command = %{echo "cd #{NAME} && DOCKER_HOST=:2375 docker exec -it ringmd_new_web_1 rails c" | ssh #{master(server)} -p 2200}
|
36
|
+
system_cmd(command)
|
37
|
+
end
|
38
|
+
|
18
39
|
private
|
19
40
|
|
20
41
|
def self.validate(server)
|
21
42
|
fail(ServerNotFound, 'Server not found in the creds file') unless exists?(server)
|
22
43
|
end
|
23
44
|
|
45
|
+
def self.validate_type(type)
|
46
|
+
fail(TypeNotFound, "Type is not in #{TYPE}") unless TYPE.include?(type)
|
47
|
+
end
|
48
|
+
|
24
49
|
def self.exists?(server)
|
25
50
|
Server.all.include?(server)
|
26
51
|
end
|
@@ -37,6 +62,10 @@ module Rmd
|
|
37
62
|
Server.get(server).master
|
38
63
|
end
|
39
64
|
|
65
|
+
def self.nginx(server)
|
66
|
+
Server.get(server).nginx
|
67
|
+
end
|
68
|
+
|
40
69
|
def self.system_cmd(cmd)
|
41
70
|
$stdout.puts(cmd)
|
42
71
|
system(cmd)
|
data/lib/rmd/server.rb
CHANGED
data/lib/rmd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duc Le
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|