dolphin 0.0.9 → 0.1.0

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: aac3d20cc20468e892bc507f3d9ea5ed5299fb0c
4
- data.tar.gz: 34571054862171bcb5c5b2a07cb139ad50e1a318
3
+ metadata.gz: 0cdebd25f15c7ca3178f5b20d2fcf659ddac74c1
4
+ data.tar.gz: bd3f80a28f9c699457432c035aab9d56f741aa27
5
5
  SHA512:
6
- metadata.gz: ba8dca1fa842d00e46e5df3737906b17ef06ea60a2f18117868c1b93516a6d4e93577fb4ac6ddab6cce9efb9c0bb4fe8252748ac11dee693e006f1a35b628a7c
7
- data.tar.gz: 9b7812bfa96f1a0f87b29809b2b3b533865e495995f543192e333cf32e237a5f5fc501464b2c44a2b45c2be421474f5fc74adbec2190fbc3ac906d94485f2308
6
+ metadata.gz: 9a8cbd6cda2c393fc43ec56837d8945c6fa5158328b7aeddadc8a8c6143c3b0215c6e716527ac1eee52b37ad0cf427ba82047c331a0e684eb6cacfe781f1e408
7
+ data.tar.gz: 40c74e0f464376b848e2e5a099a07eb7abbbe4a5a43245451404e70238ac3d12c03d15da0edbaa83afe0109610619d31f05a7062fb30d7b66bc3feb513b9da8d
data/README.md CHANGED
@@ -45,26 +45,28 @@ Edit the bin/dolphin script generated as above to adjust settings. Please refer
45
45
  @application = 'best_app'
46
46
  # on server, the user account for deploying
47
47
  @user = 'deploy'
48
+ # on server, the user group for deploying
49
+ @user_group = 'deploy'
48
50
  # location of git repository
49
51
  @github = "git@github.com:nengxu/dolphin.git"
50
52
 
51
53
  case @env
52
54
  when 'qa'
53
- @servers = [
54
- 'qa01.best_app.com',
55
- 'qa02.best_app.com',
56
- ]
55
+ @server_hash = {
56
+ q1: 'qa01.best_app.com',
57
+ q2: 'qa02.best_app.com',
58
+ }
57
59
  when 'production'
58
- @servers = [
59
- 'prod01.best_app.com',
60
- 'prod02.best_app.com',
61
- ]
60
+ @server_hash = {
61
+ p1: 'prod01.best_app.com',
62
+ p2: 'prod02.best_app.com',
63
+ }
62
64
  else # @env == 'alpha'
63
65
  # list of servers for this environment
64
- @servers = [
65
- 'dev01.best_app.com',
66
- 'dev02.best_app.com',
67
- ]
66
+ @server_hash = {
67
+ d1: 'dev01.best_app.com',
68
+ d2: 'dev02.best_app.com',
69
+ }
68
70
  # customized branch, default is the same as @env
69
71
  @branch = 'master'
70
72
  end
@@ -199,6 +201,28 @@ For example, you can start puma in production mode on your local machine:
199
201
 
200
202
  bin/dolphin puma start -e production -l
201
203
 
204
+ ### Deploy to one specific server
205
+
206
+ Sometimes we need to take some actions on only one specific server. Just pass the --target (or -t for short) option when issue command. Notice that in @server_hash, we difine a key-value pair for each server. So we only need to pass the key for that specific server as the -t option.
207
+
208
+ bin/dolphin nginx conf -t q2
209
+
210
+ Relevant settings in bin/dolphin are:
211
+
212
+ case @env
213
+ when 'qa'
214
+ @server_hash = {
215
+ q1: 'qa01.best_app.com',
216
+ q2: 'qa02.best_app.com',
217
+ }
218
+
219
+ # apply to one target server
220
+ if options[:target]
221
+ @servers = [
222
+ @server_hash[options[:target].to_sym],
223
+ ]
224
+ end
225
+
202
226
  ## Extend with custom modules
203
227
 
204
228
  To extend dolphin's functionality with your custom modules is easy. It is Ruby anyway. For example, to add Centos related functions:
@@ -10,8 +10,12 @@ class Dolphin::Base < Thor
10
10
  # class options
11
11
  # =============================================================================
12
12
 
13
- class_option :env, :aliases => '-e', :type => :string, :default => 'alpha'
14
- class_option :local, :aliases => '-l', :type => :boolean, :default => false
13
+ # deploy environment
14
+ class_option :env, aliases: '-e', type: :string, default: 'alpha'
15
+ # deploy to one specific target server
16
+ class_option :target, aliases: '-t', type: :string, default: nil
17
+ # deploy to localhost
18
+ class_option :local, aliases: '-l', type: :boolean, default: false
15
19
 
16
20
  def initialize(args=[], options={}, config={})
17
21
  super(args, options, config)
@@ -1,8 +1,8 @@
1
1
  # set up target servers
2
2
  class Dolphin::Setup < Dolphin::Base
3
3
 
4
- desc "chruby", "install chruby"
5
- def chruby
4
+ desc "chruby", "install/update chruby"
5
+ def chruby(version='v0.3.6')
6
6
  menu = [
7
7
  "
8
8
  # git clone
@@ -10,8 +10,10 @@ class Dolphin::Setup < Dolphin::Base
10
10
  cd chruby
11
11
  # update
12
12
  git fetch
13
+ git checkout master
14
+ git rebase origin/master
13
15
  # checkout tag
14
- git checkout v0.3.6
16
+ git checkout #{version}
15
17
  # install
16
18
  sudo make install
17
19
  ",
@@ -20,7 +22,19 @@ class Dolphin::Setup < Dolphin::Base
20
22
  execute menu
21
23
  end
22
24
 
23
- desc "ruby_install", "update ruby_install"
25
+ desc "app_dir", "set up app dir"
26
+ def app_dir
27
+ menu = [
28
+ "
29
+ sudo mkdir -p #{@app_dir}
30
+ sudo chown #{@user}:#{@user_group} #{@app_dir}
31
+ ",
32
+ ]
33
+
34
+ execute menu
35
+ end
36
+
37
+ desc "ruby_install", "install/update ruby_install"
24
38
  def ruby_install(version='master')
25
39
  menu = [
26
40
  "
@@ -29,6 +43,8 @@ class Dolphin::Setup < Dolphin::Base
29
43
  cd ruby-install
30
44
  # update
31
45
  git fetch
46
+ git checkout master
47
+ git rebase origin/master
32
48
  # checkout tag
33
49
  git checkout #{version}
34
50
  # install
@@ -41,6 +57,13 @@ class Dolphin::Setup < Dolphin::Base
41
57
 
42
58
  desc "repo", "repository set up."
43
59
  def repo
60
+ # branch 'master' is always created by git
61
+ if @branch == 'master'
62
+ cmd = "git checkout master"
63
+ else
64
+ cmd = "git checkout -b #{@branch} origin/#{@branch}"
65
+ end
66
+
44
67
  menu = [
45
68
  "
46
69
  # init git repository
@@ -50,7 +73,7 @@ class Dolphin::Setup < Dolphin::Base
50
73
  "
51
74
  # set up tracking branch
52
75
  cd #{@deploy_dir}
53
- git checkout -b #{@branch} origin/#{@branch}
76
+ #{cmd}
54
77
  ",
55
78
  ]
56
79
 
@@ -1,3 +1,3 @@
1
1
  module Dolphin
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -17,6 +17,8 @@ class Dolphin::Base
17
17
  @application = 'best_app'
18
18
  # on server, the user account for deploying
19
19
  @user = 'deploy'
20
+ # on server, the user group for deploying
21
+ @user_group = 'deploy'
20
22
  # location of git repository
21
23
  @github = "git@github.com:nengxu/dolphin.git"
22
24
 
@@ -48,29 +50,26 @@ class Dolphin::Base
48
50
  @env = @branch =options[:env]
49
51
 
50
52
  case @env
51
- when 'local'
52
- @servers = [
53
- 'localhost',
54
- ]
55
53
  when 'qa'
56
- @servers = [
57
- 'qa01.best_app.com',
58
- 'qa02.best_app.com',
59
- ]
54
+ @server_hash = {
55
+ q1: 'qa01.best_app.com',
56
+ q2: 'qa02.best_app.com',
57
+ }
60
58
  when 'production'
61
- @servers = [
62
- 'prod01.best_app.com',
63
- 'prod02.best_app.com',
64
- ]
59
+ @server_hash = {
60
+ p1: 'prod01.best_app.com',
61
+ p2: 'prod02.best_app.com',
62
+ }
65
63
  else # @env == 'alpha'
66
64
  # list of servers for this environment
67
- @servers = [
68
- 'dev01.best_app.com',
69
- 'dev02.best_app.com',
70
- ]
65
+ @server_hash = {
66
+ d1: 'dev01.best_app.com',
67
+ d2: 'dev02.best_app.com',
68
+ }
71
69
  # customized branch, default is the same as @env
72
70
  @branch = 'master'
73
71
  end
72
+ @servers = @server_hash.values
74
73
 
75
74
  # running in local mode
76
75
  if options[:local]
@@ -83,6 +82,13 @@ class Dolphin::Base
83
82
  ]
84
83
  end
85
84
 
85
+ # apply to one target server
86
+ if options[:target]
87
+ @servers = [
88
+ @server_hash[options[:target].to_sym],
89
+ ]
90
+ end
91
+
86
92
  # ===================================
87
93
  # settings to avoid simultaneous deployments
88
94
  # ===================================
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.0.9
4
+ version: 0.1.0
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-12 00:00:00.000000000 Z
11
+ date: 2013-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor