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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1d4dd2d187134710fb83f08399c0c03c4a0557c
4
- data.tar.gz: 2a0e88f202538bfc93925471b15a0b514f62da6f
3
+ metadata.gz: b450952394e9ced13ba04e68c784ee5fb43c6a0a
4
+ data.tar.gz: c53d8cbe6d51f234ad587ecf63192c98c1ec81e1
5
5
  SHA512:
6
- metadata.gz: 144a7016263864b2c3f26c4ec2447c35cd3637fdd67557fc096718b4fad361c7f9644a6c6d3d7ef8e4026dcfb1fe6c0881b7648e987e50116428309b557dbedc
7
- data.tar.gz: 02a339230507f359dfd833a28314eded6c568a03bab3a6a44115a652b5a5b505c2aebca040a1ddce82ca7133b1845a4b9e9c7a39492ed03c066a1ed644bef3a4
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
@@ -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
- system_cmd("curl -s #{url(server)}/deploy/#{token(server)}")
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
@@ -27,5 +27,9 @@ module Rmd
27
27
  def master
28
28
  @config['master']
29
29
  end
30
+
31
+ def nginx
32
+ @config['nginx']
33
+ end
30
34
  end
31
35
  end
data/lib/rmd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rmd
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.3
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-28 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler