dolphin 0.0.6 → 0.0.7

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: 0368b3d9bab059dd58cfb9461d066c152f455761
4
- data.tar.gz: e6caa9a6aad53d4fd2f3f1dc90c17560173a926e
3
+ metadata.gz: 7ae212bf6ffc646c027922fcf0e2a2a08c09f4bf
4
+ data.tar.gz: 6e22cdeacbde4a142c437ddf1c70660653d44539
5
5
  SHA512:
6
- metadata.gz: 7bc4d81defbd5df890af8af3bd73a144966e8c60bbaf6b8383f09c546dea0c38ba165c49c3acc0a87a3272c1037a081645349a571656cf0d8455e9eb9a30e060
7
- data.tar.gz: 51db0ccf7a148455433c178b336bb37fd89b56bbc453f6ff02bacb3944c67e0c9aaf01fdbc82bd44f4d5a41443f02c0ec27a607dd9db3a5eb5c360a412779a5b
6
+ metadata.gz: 05039c7d3921e3425fc4908c145512b20103d566213dad815eddf1cde39db4e2487f22f7a19157baa57ac82f95cb3f4a82e6e2c0eb7ecf734f3ce588d4461e9a
7
+ data.tar.gz: 620b15003c9b38b1b334fecf1b151787f7d6abf06eb3cbbe9e711f6e6e83ae0aa601ef62691868847c3b66278cc3847be339f79ac55dd33df6bbbee542d78e99
data/README.md CHANGED
@@ -12,25 +12,23 @@ Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage dep
12
12
  * Welcome, git checkout.
13
13
  * Bye bye, Rake tasks;
14
14
  * Welcome, Thor actions.
15
+ * Bye bye, RVM;
16
+ * Welcome, Chruby.
17
+ * Bye bye, gemset;
18
+ * Welcome, system wide gems.
15
19
  * Bye bye, complexity;
16
20
  * Welcome, nimbleness.
17
21
 
18
- ## Installation
22
+ ## Installation / Rails generator
19
23
 
20
24
  Add this line to your application's Gemfile:
21
25
 
22
26
  gem 'dolphin'
23
27
 
24
- And then execute:
25
-
26
- $ bundle
27
-
28
28
  Or install it yourself as:
29
29
 
30
30
  $ gem install dolphin
31
31
 
32
- ## Rails generator
33
-
34
32
  Run generator from your Rails application:
35
33
 
36
34
  $ bin/rails g dolphin:install
@@ -75,11 +73,13 @@ Edit the bin/dolphin script generated as above to adjust settings. Please refer
75
73
 
76
74
  ## Usage
77
75
 
78
- Show top level command modules:
76
+ ### Help
77
+
78
+ Show top level modules:
79
79
 
80
80
  $ bin/dolphin
81
81
 
82
- Show subcommands under one module:
82
+ Show tasks under one module:
83
83
 
84
84
  $ bin/dolphin deploy
85
85
  $ bin/dolphin git
@@ -88,10 +88,96 @@ Show subcommands under one module:
88
88
  $ bin/dolphin puma
89
89
  $ bin/dolphin setup
90
90
 
91
- Execute a subcommand, for example, normal deployment:
91
+ ### Execute a task
92
+
93
+ Each task may involve running groups of commands on the servers. So the hierarchy is like:
94
+
95
+ Module (eg., deploy / setup)
96
+ Task (eg., go / rollback)
97
+ Group (eg., check lock / update code / restart app)
98
+ Commands (eg., git fetch / git rebase)
99
+
100
+ Generally run a task in this format:
101
+
102
+ $ bin/dolphin module task argument1 argument2 -e option1 -o option2
103
+
104
+ For example, normal deployment to production:
92
105
 
93
106
  $ bin/dolphin deploy go -e production
94
107
 
108
+ Rollback to previous release in qa environment:
109
+
110
+ $ bin/dolphin deploy rollback -e qa
111
+
112
+ Switch to a specific tag / branch / commit in alpha environment:
113
+
114
+ $ bin/dolphin deploy rollback 96820cf
115
+
116
+ Please note that the default environment is alpha for developers. So there is no need to append "-e alpha" in the above example.
117
+
118
+ ### Output
119
+
120
+ The outputs from servers are captured and shown on your console as in the following sections.
121
+
122
+ #### Commands section
123
+ In this section, the list of commands from the current group is printed. For example:
124
+
125
+ $ bin/dolphin deploy try
126
+ **********Executing commands**********
127
+ cd /rails/best_app
128
+ pwd
129
+ bundle check
130
+ ============================================================
131
+
132
+ #### Capture section
133
+
134
+ In this section, the outputs from the servers are captured in realtime as they are generated. The outputs are classied in 3 types: output / error / exit. The general format of the captured output is:
135
+
136
+ server.name => [type]: result from server
137
+
138
+ Because Dolphin is running tasks on servers in multi-threaded mode, outputs from all servers are mingled together like in random order. For example:
139
+
140
+ dev01.best_app.com => [output]: /rails/best_app
141
+ dev02.best_app.com => [output]: /rails/best_app
142
+ dev02.best_app.com => [output]: The Gemfile's dependencies are satisfied
143
+ dev02.best_app.com => [exit]: 0
144
+ dev01.best_app.com => [output]: The Gemfile's dependencies are satisfied
145
+ dev01.best_app.com => [exit]: 0
146
+
147
+ Caveat! Some server applications may label their output differently than expected. So if you see some output labelled with [error], don't assume there are errors or the commands failed. For example, Git may produce such:
148
+
149
+ dev02.best_app.com => [error]: Note: checking out '96820cffcec43499acfc737bade544aa011f5376'.
150
+
151
+ You are in 'detached HEAD' state. You can look around, make experimental
152
+ changes and commit them, and you can discard any commits you make in this
153
+ state without impacting any branches by performing another checkout.
154
+
155
+ If you want to create a new branch to retain commits you create, you may
156
+ do so (now or later) by using -b with the checkout command again. Example:
157
+
158
+ git checkout -b new_branch_name
159
+
160
+ dev02.best_app.com => [error]: HEAD is now at 96820cf... Return format from gem changed.
161
+ dev02.best_app.com => [exit]: 0
162
+
163
+ #### Review section
164
+
165
+ In this section, the outputs from current command group are printed out again. However, outputs from the same server are grouped together. So you can review the results server by server.
166
+
167
+ **********Results Review**********
168
+
169
+ ============================================================
170
+ Executing on [dev01.best_app.com] =>
171
+ [output]: /rails/best_app
172
+ [output]: The Gemfile's dependencies are satisfied
173
+ [exit]: 0
174
+
175
+ ============================================================
176
+ Executing on [dev02.best_app.com] =>
177
+ [output]: /rails/best_app
178
+ [output]: The Gemfile's dependencies are satisfied
179
+ [exit]: 0
180
+
95
181
  ## Extend with custom modules
96
182
 
97
183
  To extend dolphin's functionality with your custom modules is easy. It is Ruby anyway. For example, to add Centos related functions:
data/dolphin.gemspec CHANGED
@@ -13,18 +13,22 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.description = %q{Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage deployment tool utilizes the full power of Git and Ruby.}
15
15
  spec.summary = %q{Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage deployment tool utilizes the full power of Git and Ruby.
16
- Bye bye, serial iteration over list of servers;
17
- Welcome, multi-threaded deployment using Parallel gem.
18
- Bye bye, afterthought of the multistage extension;
19
- Welcome, multi-stage deployment built in from inception.
20
- Bye bye, SVN style checkout directories on servers;
21
- Welcome, git repository on servers.
22
- Bye bye, Capistrano style symlink tricks for current / rollback;
23
- Welcome, git checkout.
24
- Bye bye, Rake tasks;
25
- Welcome, Thor actions.
26
- Bye bye, complexity;
27
- Welcome, nimbleness.
16
+ * Bye bye, serial iteration over list of servers;
17
+ * Welcome, multi-threaded deployment using Parallel gem.
18
+ * Bye bye, afterthought of the multistage extension;
19
+ * Welcome, multi-stage deployment built in from inception.
20
+ * Bye bye, SVN style checkout directories on servers;
21
+ * Welcome, git repository on servers.
22
+ * Bye bye, Capistrano style symlink tricks for current / rollback;
23
+ * Welcome, git checkout.
24
+ * Bye bye, Rake tasks;
25
+ * Welcome, Thor actions.
26
+ * Bye bye, RVM;
27
+ * Welcome, Chruby.
28
+ * Bye bye, gemset;
29
+ * Welcome, system wide gems.
30
+ * Bye bye, complexity;
31
+ * Welcome, nimbleness.
28
32
  }
29
33
 
30
34
  spec.files = `git ls-files`.split($/)
@@ -33,6 +33,23 @@ class Dolphin::Deploy < Dolphin::Base
33
33
  invoke "dolphin:lock:release"
34
34
  end
35
35
 
36
+ desc "rollback", "rollback to previous release or a specified tag"
37
+ def rollback(tag=nil)
38
+ # check lock, must explicitly not passing arguments
39
+ invoke "dolphin:lock:check", []
40
+ # put lock
41
+ invoke "dolphin:lock:create", []
42
+
43
+ # checkout tag
44
+ invoke "dolphin:git:checkout"
45
+
46
+ # restart app server
47
+ invoke "dolphin:puma:restart", []
48
+
49
+ # remove lock
50
+ invoke "dolphin:lock:release", []
51
+ end
52
+
36
53
  desc "try", "normal deploy procedure"
37
54
  def try
38
55
  menu = [
data/lib/dolphin/git.rb CHANGED
@@ -6,6 +6,8 @@ class Dolphin::Git < Dolphin::Base
6
6
  menu = [
7
7
  "
8
8
  cd #{@deploy_dir}
9
+ # Save git head info
10
+ git rev-parse HEAD > #{@head_file}
9
11
  git fetch
10
12
  git stash
11
13
  git checkout #{@branch}
@@ -18,5 +20,22 @@ class Dolphin::Git < Dolphin::Base
18
20
  execute menu
19
21
  end
20
22
 
23
+ desc "checkout", "Checkout a specific tag, assume the code on server is up to date"
24
+ def checkout(tag=nil)
25
+ if tag
26
+ command = "git checkout #{tag}"
27
+ else
28
+ command = "git checkout `cat #{@head_file}`"
29
+ end
30
+ menu = [
31
+ "
32
+ cd #{@deploy_dir}
33
+ #{command}
34
+ ",
35
+ ]
36
+
37
+ execute menu
38
+ end
39
+
21
40
  end
22
41
 
@@ -1,3 +1,3 @@
1
1
  module Dolphin
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -84,6 +84,8 @@ class Dolphin::Base
84
84
  @deploy_date = Time.now.strftime("%m%d%H%M")
85
85
  # custom content for the lock file
86
86
  @lock_message = "Deploy started at #{@deploy_date} in progress\n"
87
+ # name and location of the head file to store git head info
88
+ @head_file = "#{@deploy_dir}/tmp/pids/head.txt"
87
89
 
88
90
  end
89
91
  end
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.6
4
+ version: 0.0.7
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-06-19 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -138,13 +138,14 @@ rubygems_version: 2.0.2
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: 'Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage
141
- deployment tool utilizes the full power of Git and Ruby. Bye bye, serial iteration
142
- over list of servers; Welcome, multi-threaded deployment using Parallel gem. Bye
143
- bye, afterthought of the multistage extension; Welcome, multi-stage deployment built
144
- in from inception. Bye bye, SVN style checkout directories on servers; Welcome,
145
- git repository on servers. Bye bye, Capistrano style symlink tricks for current
146
- / rollback; Welcome, git checkout. Bye bye, Rake tasks; Welcome, Thor actions. Bye
147
- bye, complexity; Welcome, nimbleness.'
141
+ deployment tool utilizes the full power of Git and Ruby. * Bye bye, serial iteration
142
+ over list of servers; * Welcome, multi-threaded deployment using Parallel gem. *
143
+ Bye bye, afterthought of the multistage extension; * Welcome, multi-stage deployment
144
+ built in from inception. * Bye bye, SVN style checkout directories on servers; *
145
+ Welcome, git repository on servers. * Bye bye, Capistrano style symlink tricks for
146
+ current / rollback; * Welcome, git checkout. * Bye bye, Rake tasks; * Welcome, Thor
147
+ actions. * Bye bye, RVM; * Welcome, Chruby. * Bye bye, gemset; * Welcome, system
148
+ wide gems. * Bye bye, complexity; * Welcome, nimbleness.'
148
149
  test_files:
149
150
  - spec/dolphin/base_spec.rb
150
151
  - spec/dolphin/deploy_spec.rb