dolphin 0.1.1 → 0.1.2

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: df915c5f7dbaac8d7a2e3904d4bfa6ba128ed99d
4
- data.tar.gz: 1054605420d1488164062a8d4c5a49f4d822873b
3
+ metadata.gz: 12547564e16718ea3e9836ba2235379f7e7911e2
4
+ data.tar.gz: 56d227a850dc4aa2002e61b0c04a7037250962b0
5
5
  SHA512:
6
- metadata.gz: 96461fe1ef517739578562d155e6a5921321f4f7c2627419a542d0647f712306a84a78d7f02aeebe176c0c9121d1a38c4a5a240af824a6b00b3f84dc029d7ed3
7
- data.tar.gz: 5d8a93ccbde600fcc4342dc7b4597a6b607fccef8c6a4b96a5aaf16f7edcd31c773dd4a2d0a820b5169a673dbe28aded71e31a17fa64c8fdd96ef3ce4f4f682d
6
+ metadata.gz: c5d4394fbd05a7f634721d1155f77e0daf7b83c339e423cac74f049ba415e6272fa0452c4fee2462d974d7fa862954716b8fb5297ca08d8d18fa9ba565ceecb0
7
+ data.tar.gz: f00a9af78d0b52c85eb7ab296908c7f0a088c1e31f6eca739e86b12b6da9c3563b116fc474bc492392666d0f90db0ca7e88853877467e7439694b39e72b548ad
data/README.md CHANGED
@@ -249,6 +249,25 @@ Relevant settings in bin/dolphin are:
249
249
  ]
250
250
  end
251
251
 
252
+ ### Deploy to one specific group
253
+
254
+ Sometimes we need to take some actions on only one specific group, which may contains arbitrary number of servers. Just pass the --group (or -g for short) option when issue command. Notice that in @group_hash, we difine a key-value pair for each group. So we only need to pass the key for that specific group as the -g option.
255
+
256
+ bin/dolphin nginx conf -t q2
257
+
258
+ Relevant settings in bin/dolphin are:
259
+
260
+ @group_hash = {
261
+ mongo: [:mongo1, :mongo2, :mongo3, ],
262
+ java: [:graylog, :elasticsearch, ],
263
+ app: [:app1, :app2, ],
264
+ }
265
+
266
+ # apply to one target group
267
+ if options[:group]
268
+ @servers = @group_hash[options[:group].to_sym].map {|item| @server_hash[item]}
269
+ end
270
+
252
271
  ## Extend with custom modules
253
272
 
254
273
  To extend dolphin's functionality with your custom modules is easy. It is Ruby anyway. For example, to add Centos related functions:
@@ -14,6 +14,8 @@ class Dolphin::Base < Thor
14
14
  class_option :env, aliases: '-e', type: :string, default: 'alpha'
15
15
  # deploy to one specific target server
16
16
  class_option :target, aliases: '-t', type: :string, default: nil
17
+ # deploy to one specific server group
18
+ class_option :group, aliases: '-g', type: :string, default: nil
17
19
  # deploy to localhost
18
20
  class_option :local, aliases: '-l', type: :boolean, default: false
19
21
 
@@ -139,7 +141,7 @@ class Dolphin::Base < Thor
139
141
  end
140
142
 
141
143
  # has to explicitly call shell startup script
142
- ch.send_data "source ~/.bash_profile\n"
144
+ ch.send_data "source ~/.bashrc\n"
143
145
 
144
146
  # pick up ruby
145
147
  ch.send_data "chruby >& /dev/null\n"
@@ -169,4 +171,23 @@ class Dolphin::Base < Thor
169
171
  puts "\n\n"
170
172
  end
171
173
 
174
+ def upload(source, dest, target_server=nil)
175
+ if target_server # solo
176
+ tracks = 1
177
+ target = [target_server]
178
+ else
179
+ # use Parallel to execute commands on multiple servers in parallel
180
+ tracks = @servers.size
181
+ # 3 threads maximum
182
+ tracks = 3 if tracks > 3
183
+ target = @servers
184
+ end
185
+
186
+ Parallel.map(target, in_threads: tracks) do |server|
187
+ command = "scp #{source} #{@user}@#{server}:#{dest}"
188
+ puts command
189
+ raise unless system(command, out: $stdout, err: :out)
190
+ end
191
+ end
192
+
172
193
  end
@@ -6,7 +6,7 @@ class Dolphin::Puma < Dolphin::Base
6
6
  menu = [
7
7
  "
8
8
  cd #{@deploy_dir}
9
- RAILS_ENV=#{@env} bundle exec puma -C config/puma.rb
9
+ RAILS_ENV=#{@env} bundle exec puma -C #{@deploy_dir}/config/puma.rb
10
10
  ",
11
11
  ]
12
12
 
@@ -2,7 +2,7 @@
2
2
  class Dolphin::Setup < Dolphin::Base
3
3
 
4
4
  desc "chruby", "install/update chruby"
5
- def chruby(version='v0.3.6')
5
+ def chruby(version='v0.3.7')
6
6
  menu = [
7
7
  "
8
8
  # git clone
@@ -16,6 +16,9 @@ class Dolphin::Setup < Dolphin::Base
16
16
  git checkout #{version}
17
17
  # install
18
18
  sudo make install
19
+ # system wise
20
+ # sudo echo '[ -n \"$BASH_VERSION\" ] || [ -n \"$ZSH_VERSION\" ] || return' | sudo tee /etc/profile.d/chruby.sh
21
+ # sudo echo 'source /usr/local/share/chruby/chruby.sh' | sudo tee -a /etc/profile.d/chruby.sh
19
22
  ",
20
23
  ]
21
24
 
@@ -1,3 +1,3 @@
1
1
  module Dolphin
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -56,9 +56,21 @@ class Dolphin::Base
56
56
  }
57
57
  when 'production'
58
58
  @server_hash = {
59
- p1: 'prod01.best_app.com',
60
- p2: 'prod02.best_app.com',
59
+ app1: 'app1.best_app.com',
60
+ app2: 'app2.best_app.com',
61
+ mongo1: 'mongo1.best_app.com',
62
+ mongo2: 'mongo2.best_app.com',
63
+ mongo3: 'mongo3.best_app.com',
64
+ graylog: 'graylog.best_app.com',
65
+ elasticsearch: 'elasticsearch.best_app.com',
61
66
  }
67
+
68
+ @group_hash = {
69
+ mongo: [:mongo1, :mongo2, :mongo3, ],
70
+ java: [:graylog, :elasticsearch, ],
71
+ app: [:app1, :app2, ],
72
+ }
73
+
62
74
  else # @env == 'alpha'
63
75
  # list of servers for this environment
64
76
  @server_hash = {
@@ -88,6 +100,11 @@ class Dolphin::Base
88
100
  ]
89
101
  end
90
102
 
103
+ # apply to one target group
104
+ if options[:group]
105
+ @servers = @group_hash[options[:group].to_sym].map {|item| @server_hash[item]}
106
+ end
107
+
91
108
  # ===================================
92
109
  # settings to avoid simultaneous deployments
93
110
  # ===================================
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolphin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neng Xu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-23 00:00:00.000000000 Z
11
+ date: 2013-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor