dolphin 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -0
- data/lib/dolphin.rb +6 -274
- data/lib/dolphin/git.rb +22 -0
- data/lib/dolphin/nginx.rb +70 -0
- data/lib/dolphin/puma.rb +42 -0
- data/lib/dolphin/setup.rb +83 -0
- data/lib/dolphin/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3c7b54501a8a9b956d5f64dc057f056400d4719
|
4
|
+
data.tar.gz: bba03a660905487e6fa96b7f0dcab409e43dde5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d37afe7c4a899c9274c638029eca78b731dcb41fda88b612c9d836a5f3ef0816ca812a4b1932e4067aaaf297b476e7f70d708a1cb739fe6128345e2988022e88
|
7
|
+
data.tar.gz: d0983df1a404ef3fcf0c35a44379d849e309980e2c27dc08e05c8f8ea41e380a60791c2efd9c5488bdb9667b2a22443790ba713e8c5cb0dc3e34afcef3907272
|
data/README.md
CHANGED
@@ -79,6 +79,44 @@ Execute a subcommand, for example, normal deployment:
|
|
79
79
|
|
80
80
|
$ bin/dolphin deploy go -e production
|
81
81
|
|
82
|
+
## Extend with custom modules
|
83
|
+
|
84
|
+
To extend dolphin's functionality with your custom modules is easy. It is Ruby anyway. For example, to add Centos related functions:
|
85
|
+
|
86
|
+
# bin/dolphin
|
87
|
+
# adjust Centos config
|
88
|
+
class Dolphin::Centos < Dolphin::Base
|
89
|
+
desc "git", "install latest git"
|
90
|
+
def git
|
91
|
+
menu = [
|
92
|
+
"
|
93
|
+
# install rpmforge
|
94
|
+
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
95
|
+
wget http://apt.sw.be/RPM-GPG-KEY.dag.txt
|
96
|
+
sudo rpm --import RPM-GPG-KEY.dag.txt
|
97
|
+
sudo rpm -K rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
98
|
+
sudo rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
99
|
+
sudo cp ~/rpmforge.repo /etc/yum.repos.d/
|
100
|
+
|
101
|
+
# list repos
|
102
|
+
# yum repolist
|
103
|
+
|
104
|
+
# install git
|
105
|
+
sudo yum -y remove git
|
106
|
+
sudo yum clean all
|
107
|
+
sudo yum -y update
|
108
|
+
sudo yum -y install git
|
109
|
+
",
|
110
|
+
]
|
111
|
+
|
112
|
+
execute menu
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class Dolphin::CLI < Thor
|
117
|
+
register(Dolphin::Centos, 'centos', 'centos', 'Adjust Centos config')
|
118
|
+
end
|
119
|
+
|
82
120
|
## Related gems
|
83
121
|
|
84
122
|
* [capistrano]
|
data/lib/dolphin.rb
CHANGED
@@ -2,287 +2,19 @@ require_relative "dolphin/version"
|
|
2
2
|
require_relative "dolphin/base"
|
3
3
|
require_relative "dolphin/lock"
|
4
4
|
require_relative "dolphin/deploy"
|
5
|
+
require_relative "dolphin/setup"
|
6
|
+
require_relative "dolphin/nginx"
|
7
|
+
require_relative "dolphin/puma"
|
8
|
+
require_relative "dolphin/git"
|
5
9
|
|
6
10
|
module Dolphin
|
7
11
|
|
8
|
-
# =============================================================================
|
9
|
-
# Setup
|
10
|
-
# =============================================================================
|
11
|
-
class Setup < Base
|
12
|
-
desc "chruby", "install chruby"
|
13
|
-
def chruby
|
14
|
-
menu = [
|
15
|
-
"
|
16
|
-
# git clone
|
17
|
-
if [ ! -d 'chruby' ]; then git clone https://github.com/postmodern/chruby.git ; fi
|
18
|
-
# checkout tag
|
19
|
-
cd chruby
|
20
|
-
git checkout v0.3.5
|
21
|
-
# install
|
22
|
-
sudo make install
|
23
|
-
",
|
24
|
-
]
|
25
|
-
|
26
|
-
execute menu
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "repo", "repository set up."
|
30
|
-
def repo
|
31
|
-
menu = [
|
32
|
-
"
|
33
|
-
# init git repository
|
34
|
-
cd #{@app_dir}
|
35
|
-
git clone #{@github}
|
36
|
-
",
|
37
|
-
"
|
38
|
-
# set up tracking branch
|
39
|
-
cd #{@deploy_dir}
|
40
|
-
git checkout -b #{@branch} origin/#{@branch}
|
41
|
-
",
|
42
|
-
]
|
43
|
-
|
44
|
-
execute menu
|
45
|
-
end
|
46
|
-
|
47
|
-
desc "ruby", "install ruby, arg: version"
|
48
|
-
def ruby(version="2.0.0-p195")
|
49
|
-
menu = [
|
50
|
-
"
|
51
|
-
# update ruby-build
|
52
|
-
cd ruby-build
|
53
|
-
git pull
|
54
|
-
sudo ./install.sh
|
55
|
-
",
|
56
|
-
"
|
57
|
-
# install ruby
|
58
|
-
sudo ruby-build #{version} /opt/rubies/ruby-#{version}
|
59
|
-
",
|
60
|
-
]
|
61
|
-
|
62
|
-
execute menu
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "select", "select ruby, arg: version"
|
66
|
-
def select(version="2.0.0-p195")
|
67
|
-
menu = [
|
68
|
-
"
|
69
|
-
# select ruby
|
70
|
-
cd #{@app_dir}
|
71
|
-
echo ruby-#{version} > .ruby-version
|
72
|
-
",
|
73
|
-
]
|
74
|
-
|
75
|
-
execute menu
|
76
|
-
end
|
77
|
-
|
78
|
-
desc "bundler", "install bundler"
|
79
|
-
def bundler
|
80
|
-
menu = [
|
81
|
-
"
|
82
|
-
# install bundler
|
83
|
-
sudo gem install bundler
|
84
|
-
",
|
85
|
-
]
|
86
|
-
|
87
|
-
execute menu
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "rvm", "remove rvm"
|
91
|
-
def rvm
|
92
|
-
menu = [
|
93
|
-
"
|
94
|
-
sudo yum -y remove move-rvm
|
95
|
-
sudo rm -rf /usr/local/rvm
|
96
|
-
",
|
97
|
-
]
|
98
|
-
|
99
|
-
execute menu
|
100
|
-
end
|
101
|
-
|
102
|
-
desc "apache", "remove apache"
|
103
|
-
def apache
|
104
|
-
menu = [
|
105
|
-
"
|
106
|
-
sudo chkconfig httpd.newhomesapi off
|
107
|
-
sudo chkconfig httpd.newhomesrdc off
|
108
|
-
sudo yum -y remove httpd
|
109
|
-
",
|
110
|
-
]
|
111
|
-
|
112
|
-
execute menu
|
113
|
-
end
|
114
|
-
|
115
|
-
desc "git", "install latest git"
|
116
|
-
def git
|
117
|
-
menu = [
|
118
|
-
"
|
119
|
-
# install rpmforge
|
120
|
-
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
121
|
-
wget http://apt.sw.be/RPM-GPG-KEY.dag.txt
|
122
|
-
sudo rpm --import RPM-GPG-KEY.dag.txt
|
123
|
-
sudo rpm -K rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
124
|
-
sudo rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
|
125
|
-
sudo cp ~/rpmforge.repo /etc/yum.repos.d/
|
126
|
-
|
127
|
-
# list repos
|
128
|
-
# yum repolist
|
129
|
-
|
130
|
-
# install git
|
131
|
-
sudo yum -y remove git
|
132
|
-
sudo yum clean all
|
133
|
-
sudo yum -y update
|
134
|
-
sudo yum -y install git
|
135
|
-
",
|
136
|
-
]
|
137
|
-
|
138
|
-
execute menu
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
# =============================================================================
|
144
|
-
# Nginx
|
145
|
-
# =============================================================================
|
146
|
-
class Nginx < Base
|
147
|
-
desc "install", "install nginx"
|
148
|
-
def install
|
149
|
-
menu = [
|
150
|
-
"
|
151
|
-
# set repo
|
152
|
-
sudo cp ~/nginx.repo /etc/yum.repos.d/
|
153
|
-
|
154
|
-
# list repos
|
155
|
-
# yum repolist
|
156
|
-
|
157
|
-
# install nginx
|
158
|
-
sudo yum -y install nginx
|
159
|
-
",
|
160
|
-
]
|
161
|
-
|
162
|
-
execute menu
|
163
|
-
end
|
164
|
-
|
165
|
-
desc "conf", "config nginx"
|
166
|
-
def conf
|
167
|
-
menu = [
|
168
|
-
"
|
169
|
-
sudo ln -sf #{@deploy_dir}/config/nginx/#{@application}.conf /etc/nginx/conf.d/#{@application}.conf
|
170
|
-
",
|
171
|
-
]
|
172
|
-
|
173
|
-
execute menu
|
174
|
-
end
|
175
|
-
|
176
|
-
desc "start", "start nginx"
|
177
|
-
def start
|
178
|
-
menu = [
|
179
|
-
"
|
180
|
-
# common settings
|
181
|
-
sudo service nginx start
|
182
|
-
",
|
183
|
-
]
|
184
|
-
|
185
|
-
execute menu
|
186
|
-
end
|
187
|
-
|
188
|
-
desc "stop", "stop nginx"
|
189
|
-
def stop
|
190
|
-
menu = [
|
191
|
-
"
|
192
|
-
# common settings
|
193
|
-
sudo service nginx stop
|
194
|
-
",
|
195
|
-
]
|
196
|
-
|
197
|
-
execute menu
|
198
|
-
end
|
199
|
-
|
200
|
-
desc "restart", "restart nginx"
|
201
|
-
def restart
|
202
|
-
menu = [
|
203
|
-
"
|
204
|
-
# common settings
|
205
|
-
sudo service nginx restart
|
206
|
-
",
|
207
|
-
]
|
208
|
-
|
209
|
-
execute menu
|
210
|
-
end
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
# =============================================================================
|
215
|
-
# Git
|
216
|
-
# =============================================================================
|
217
|
-
class Git < Base
|
218
|
-
desc "update", "Update code from github and keep local changes"
|
219
|
-
def update
|
220
|
-
menu = [
|
221
|
-
"
|
222
|
-
cd #{@deploy_dir}
|
223
|
-
git fetch
|
224
|
-
git stash
|
225
|
-
git checkout #{@branch}
|
226
|
-
git rebase origin/#{@branch}
|
227
|
-
git stash apply
|
228
|
-
git stash clear
|
229
|
-
",
|
230
|
-
]
|
231
|
-
|
232
|
-
execute menu
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
# =============================================================================
|
238
|
-
# Puma
|
239
|
-
# =============================================================================
|
240
|
-
class Puma < Base
|
241
|
-
desc "start", "start puma"
|
242
|
-
def start
|
243
|
-
menu = [
|
244
|
-
"
|
245
|
-
cd #{@deploy_dir}
|
246
|
-
RAILS_ENV=#{@env} bundle exec puma -t 8:32 -e #{@env} -d -b unix://#{@sockets}/#{@application}.sock -S #{@pids}/#{@application}.state --control unix://#{@sockets}/pumactl.sock --pidfile #{@pids}/#{@application}.pid
|
247
|
-
",
|
248
|
-
]
|
249
|
-
|
250
|
-
execute menu
|
251
|
-
end
|
252
|
-
|
253
|
-
desc "stop", "stop puma"
|
254
|
-
def stop
|
255
|
-
menu = [
|
256
|
-
"
|
257
|
-
cd #{@deploy_dir}
|
258
|
-
RAILS_ENV=#{@env} bundle exec pumactl -S #{@pids}/#{@application}.state stop
|
259
|
-
",
|
260
|
-
]
|
261
|
-
|
262
|
-
execute menu
|
263
|
-
end
|
264
|
-
|
265
|
-
desc "restart", "restart puma"
|
266
|
-
def restart
|
267
|
-
menu = [
|
268
|
-
"
|
269
|
-
cd #{@deploy_dir}
|
270
|
-
# RAILS_ENV=#{@env} bundle exec pumactl -S #{@pids}/#{@application}.state restart
|
271
|
-
kill -s SIGUSR2 `cat #{@pids}/#{@application}.pid`
|
272
|
-
",
|
273
|
-
]
|
274
|
-
|
275
|
-
execute menu
|
276
|
-
end
|
277
|
-
|
278
|
-
end
|
279
|
-
|
280
12
|
# =============================================================================
|
281
13
|
# CLI
|
282
14
|
# =============================================================================
|
283
15
|
class CLI < Thor
|
284
|
-
register(Setup, 'setup', 'setup', '
|
285
|
-
register(Deploy, 'deploy', 'deploy', '
|
16
|
+
register(Setup, 'setup', 'setup', 'Set up target servers')
|
17
|
+
register(Deploy, 'deploy', 'deploy', 'Deploy to target server')
|
286
18
|
register(Puma, 'puma', 'puma', 'Puma related commands')
|
287
19
|
register(Nginx, 'nginx', 'nginx', 'Nginx related commands')
|
288
20
|
register(Git, 'git', 'git', 'Git related commands')
|
data/lib/dolphin/git.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Git related commands
|
2
|
+
class Dolphin::Git < Dolphin::Base
|
3
|
+
|
4
|
+
desc "update", "Update code from github and keep local changes"
|
5
|
+
def update
|
6
|
+
menu = [
|
7
|
+
"
|
8
|
+
cd #{@deploy_dir}
|
9
|
+
git fetch
|
10
|
+
git stash
|
11
|
+
git checkout #{@branch}
|
12
|
+
git rebase origin/#{@branch}
|
13
|
+
git stash apply
|
14
|
+
git stash clear
|
15
|
+
",
|
16
|
+
]
|
17
|
+
|
18
|
+
execute menu
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Nginx related commands
|
2
|
+
class Dolphin::Nginx < Dolphin::Base
|
3
|
+
|
4
|
+
desc "install", "install nginx"
|
5
|
+
def install
|
6
|
+
menu = [
|
7
|
+
"
|
8
|
+
# set repo
|
9
|
+
sudo cp ~/nginx.repo /etc/yum.repos.d/
|
10
|
+
|
11
|
+
# list repos
|
12
|
+
# yum repolist
|
13
|
+
|
14
|
+
# install nginx
|
15
|
+
sudo yum -y install nginx
|
16
|
+
",
|
17
|
+
]
|
18
|
+
|
19
|
+
execute menu
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "conf", "config nginx"
|
23
|
+
def conf
|
24
|
+
menu = [
|
25
|
+
"
|
26
|
+
sudo ln -sf #{@deploy_dir}/config/nginx/#{@application}.conf /etc/nginx/conf.d/#{@application}.conf
|
27
|
+
",
|
28
|
+
]
|
29
|
+
|
30
|
+
execute menu
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "start", "start nginx"
|
34
|
+
def start
|
35
|
+
menu = [
|
36
|
+
"
|
37
|
+
# common settings
|
38
|
+
sudo service nginx start
|
39
|
+
",
|
40
|
+
]
|
41
|
+
|
42
|
+
execute menu
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "stop", "stop nginx"
|
46
|
+
def stop
|
47
|
+
menu = [
|
48
|
+
"
|
49
|
+
# common settings
|
50
|
+
sudo service nginx stop
|
51
|
+
",
|
52
|
+
]
|
53
|
+
|
54
|
+
execute menu
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "restart", "restart nginx"
|
58
|
+
def restart
|
59
|
+
menu = [
|
60
|
+
"
|
61
|
+
# common settings
|
62
|
+
sudo service nginx restart
|
63
|
+
",
|
64
|
+
]
|
65
|
+
|
66
|
+
execute menu
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
data/lib/dolphin/puma.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Puma related commands
|
2
|
+
class Dolphin::Puma < Dolphin::Base
|
3
|
+
|
4
|
+
desc "start", "start puma"
|
5
|
+
def start
|
6
|
+
menu = [
|
7
|
+
"
|
8
|
+
cd #{@deploy_dir}
|
9
|
+
RAILS_ENV=#{@env} bundle exec puma -t 8:32 -e #{@env} -d -b unix://#{@sockets}/#{@application}.sock -S #{@pids}/#{@application}.state --control unix://#{@sockets}/pumactl.sock --pidfile #{@pids}/#{@application}.pid
|
10
|
+
",
|
11
|
+
]
|
12
|
+
|
13
|
+
execute menu
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "stop", "stop puma"
|
17
|
+
def stop
|
18
|
+
menu = [
|
19
|
+
"
|
20
|
+
cd #{@deploy_dir}
|
21
|
+
RAILS_ENV=#{@env} bundle exec pumactl -S #{@pids}/#{@application}.state stop
|
22
|
+
",
|
23
|
+
]
|
24
|
+
|
25
|
+
execute menu
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "restart", "restart puma"
|
29
|
+
def restart
|
30
|
+
menu = [
|
31
|
+
"
|
32
|
+
cd #{@deploy_dir}
|
33
|
+
# RAILS_ENV=#{@env} bundle exec pumactl -S #{@pids}/#{@application}.state restart
|
34
|
+
kill -s SIGUSR2 `cat #{@pids}/#{@application}.pid`
|
35
|
+
",
|
36
|
+
]
|
37
|
+
|
38
|
+
execute menu
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# set up target servers
|
2
|
+
class Dolphin::Setup < Dolphin::Base
|
3
|
+
|
4
|
+
desc "chruby", "install chruby"
|
5
|
+
def chruby
|
6
|
+
menu = [
|
7
|
+
"
|
8
|
+
# git clone
|
9
|
+
if [ ! -d 'chruby' ]; then git clone https://github.com/postmodern/chruby.git ; fi
|
10
|
+
# checkout tag
|
11
|
+
cd chruby
|
12
|
+
git checkout v0.3.5
|
13
|
+
# install
|
14
|
+
sudo make install
|
15
|
+
",
|
16
|
+
]
|
17
|
+
|
18
|
+
execute menu
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "repo", "repository set up."
|
22
|
+
def repo
|
23
|
+
menu = [
|
24
|
+
"
|
25
|
+
# init git repository
|
26
|
+
cd #{@app_dir}
|
27
|
+
git clone #{@github}
|
28
|
+
",
|
29
|
+
"
|
30
|
+
# set up tracking branch
|
31
|
+
cd #{@deploy_dir}
|
32
|
+
git checkout -b #{@branch} origin/#{@branch}
|
33
|
+
",
|
34
|
+
]
|
35
|
+
|
36
|
+
execute menu
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "ruby", "install ruby, arg: version"
|
40
|
+
def ruby(version="2.0.0-p195")
|
41
|
+
menu = [
|
42
|
+
"
|
43
|
+
# update ruby-build
|
44
|
+
cd ruby-build
|
45
|
+
git pull
|
46
|
+
sudo ./install.sh
|
47
|
+
",
|
48
|
+
"
|
49
|
+
# install ruby
|
50
|
+
sudo ruby-build #{version} /opt/rubies/ruby-#{version}
|
51
|
+
",
|
52
|
+
]
|
53
|
+
|
54
|
+
execute menu
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "select", "select ruby, arg: version"
|
58
|
+
def select(version="2.0.0-p195")
|
59
|
+
menu = [
|
60
|
+
"
|
61
|
+
# select ruby
|
62
|
+
cd #{@app_dir}
|
63
|
+
echo ruby-#{version} > .ruby-version
|
64
|
+
",
|
65
|
+
]
|
66
|
+
|
67
|
+
execute menu
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "bundler", "install bundler"
|
71
|
+
def bundler
|
72
|
+
menu = [
|
73
|
+
"
|
74
|
+
# install bundler
|
75
|
+
sudo gem install bundler
|
76
|
+
",
|
77
|
+
]
|
78
|
+
|
79
|
+
execute menu
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
data/lib/dolphin/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -96,7 +96,11 @@ files:
|
|
96
96
|
- lib/dolphin.rb
|
97
97
|
- lib/dolphin/base.rb
|
98
98
|
- lib/dolphin/deploy.rb
|
99
|
+
- lib/dolphin/git.rb
|
99
100
|
- lib/dolphin/lock.rb
|
101
|
+
- lib/dolphin/nginx.rb
|
102
|
+
- lib/dolphin/puma.rb
|
103
|
+
- lib/dolphin/setup.rb
|
100
104
|
- lib/dolphin/version.rb
|
101
105
|
- lib/generators/dolphin/install_generator.rb
|
102
106
|
- lib/generators/dolphin/templates/dolphin
|