mina-rails-tools 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mina/extras/apt.rb +18 -18
- data/lib/mina/extras/brew.rb +1 -1
- data/lib/mina/extras/extra.rb +3 -3
- data/lib/mina/extras/gem.rb +4 -4
- data/lib/mina/extras/god.rb +20 -20
- data/lib/mina/extras/local.rb +1 -1
- data/lib/mina/extras/methods.rb +33 -33
- data/lib/mina/extras/mysql.rb +1 -1
- data/lib/mina/extras/nginx.rb +7 -7
- data/lib/mina/extras/platform.rb +6 -6
- data/lib/mina/extras/rails.rb +2 -2
- data/lib/mina/extras/rainbows.rb +9 -9
- data/lib/mina/extras/redis.rb +1 -1
- data/lib/mina/extras/system.rb +3 -3
- data/lib/mina/extras/ubuntu.rb +49 -49
- data/lib/mina/extras/unicorn.rb +12 -12
- data/lib/mina/extras/version.rb +1 -1
- data/mina-rails-tools.gemspec +1 -1
- data/samples/osx/config/deploy.rb +3 -3
- data/samples/rails/config/deploy.rb +40 -0
- data/samples/ubuntu/config/deploy.rb +2 -2
- data/samples/ubuntu/prepare.sh +2 -0
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1ec0a24ccf8326ac0f432baee756bf25e0191f
|
4
|
+
data.tar.gz: c69caa75b329a4320855f9458a5ff9187a2dddaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b7bbfb3051c57118b6302a15ea8a45df6ebd8298686637145f48d83b44f7d1db5144d8d32085e65e3be0cf33cbaf2e53741405f0215f962c1e97a7f4d21ec41
|
7
|
+
data.tar.gz: 0d577df6d81c040332d449ca6806c5bd1d7342410723018bff29479aec0479e4ce29cba36290592ed8ce3adfedea69849169c954911f7fe17a883e069ddcaf1f
|
data/lib/mina/extras/apt.rb
CHANGED
@@ -1,66 +1,66 @@
|
|
1
1
|
set_default :apt_source, :us
|
2
2
|
|
3
3
|
def apt_get(package)
|
4
|
-
|
4
|
+
command echo_cmd "sudo apt-get install #{package} -y"
|
5
5
|
end
|
6
6
|
|
7
7
|
namespace :apt do
|
8
8
|
namespace :get do
|
9
|
-
|
9
|
+
|
10
10
|
task :install do
|
11
11
|
apt_get("#{ENV["i"]}")
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
task :update do
|
15
|
-
|
15
|
+
command "sudo apt-get update"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
task :nginx do
|
19
19
|
apt_get("nginx")
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
task :git do
|
23
23
|
apt_get("git-core")
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
task :redis do
|
27
27
|
apt_get("redis-server")
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
task :mysql do
|
31
|
-
apt_get("mysql-server-5.
|
31
|
+
apt_get("mysql-server-5.6")
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
task :"build-essential" do
|
35
35
|
apt_get("build-essential")
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
task :"libmysqlclient-dev" do
|
39
39
|
apt_get("libmysqlclient-dev")
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
task :"libssl-dev" do
|
43
43
|
apt_get("libssl-dev")
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
task :"libreadline-dev" do
|
47
47
|
apt_get("libreadline-dev")
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
task :"libsqlite3-dev" do
|
51
51
|
apt_get("libsqlite3-dev")
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
task :"python-setuptools" do
|
55
55
|
apt_get("python-setuptools")
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
task :imagemagick do
|
59
59
|
apt_get("imagemagick")
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
task :"libmagickwand-dev" do
|
63
63
|
apt_get("libmagickwand-dev")
|
64
64
|
end
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
data/lib/mina/extras/brew.rb
CHANGED
data/lib/mina/extras/extra.rb
CHANGED
@@ -27,10 +27,10 @@ task :setup => :environment do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
command %{echo "-----> (!!!) You now need to run 'mina sudoer_setup' to run the parts that require sudoer user (!!!)"}
|
31
31
|
|
32
32
|
# if sudoer?
|
33
|
-
#
|
33
|
+
# command %{echo "-----> (!!!) You now need to run 'mina sudoer_setup' to run the parts that require sudoer user (!!!)"}
|
34
34
|
# else
|
35
35
|
# invoke :sudoer_setup
|
36
36
|
# end
|
@@ -57,7 +57,7 @@ namespace :extra do
|
|
57
57
|
end.uniq
|
58
58
|
|
59
59
|
folders.map do |dir|
|
60
|
-
|
60
|
+
command echo_cmd %{mkdir -p "#{deploy_to}/shared/#{dir}"}
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/lib/mina/extras/gem.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
def gem_install(package, options=nil)
|
2
|
-
|
2
|
+
command echo_cmd "sudo gem install #{package} #{options} --no-rdoc --no-ri"
|
3
3
|
end
|
4
4
|
|
5
5
|
namespace :gem do
|
@@ -11,13 +11,13 @@ namespace :gem do
|
|
11
11
|
namespace :source do
|
12
12
|
task :prepare do
|
13
13
|
if in_china?
|
14
|
-
|
15
|
-
|
14
|
+
command echo_cmd "sudo gem source -a http://ruby.taobao.org/"
|
15
|
+
command echo_cmd "sudo gem source -r https://rubygems.org/"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
task :list do
|
20
|
-
|
20
|
+
command echo_cmd "sudo gem source"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
data/lib/mina/extras/god.rb
CHANGED
@@ -10,44 +10,44 @@ set :use_god, true
|
|
10
10
|
namespace :god do
|
11
11
|
|
12
12
|
task :setup do
|
13
|
-
|
13
|
+
command echo_cmd "sudo mkdir -p #{god_path}/conf"
|
14
14
|
end
|
15
15
|
|
16
16
|
task :link do
|
17
17
|
extra_echo "Relocate god script file"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
command echo_cmd %{sudo rm -rf "#{god_service_path}/god"}
|
19
|
+
command echo_cmd "sudo mkdir -p #{god_path}/conf"
|
20
|
+
command echo_cmd "sudo chown -R #{user} #{god_path}"
|
21
|
+
command echo_cmd %{sudo cp "#{god_path}/god.sh" "#{god_service_path}/god"}
|
22
|
+
command echo_cmd %{sudo chown #{god_user}:#{god_group} "#{god_service_path}/god"}
|
23
|
+
command echo_cmd %{sudo chmod +x "#{god_service_path}/god"}
|
24
|
+
command echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
|
25
|
+
command echo_cmd "sudo update-rc.d god defaults"
|
26
26
|
end
|
27
27
|
|
28
28
|
task :tmp_add_permission do
|
29
|
-
|
29
|
+
command echo_cmd "sudo chown -R #{user} #{god_path}"
|
30
30
|
end
|
31
31
|
|
32
32
|
task :set_permission do
|
33
|
-
|
33
|
+
command echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
|
34
34
|
end
|
35
35
|
|
36
36
|
task :upload => [:'upload:script', :'upload:global']
|
37
37
|
|
38
38
|
namespace :upload do
|
39
39
|
task :script do
|
40
|
-
|
41
|
-
|
40
|
+
command echo_cmd "sudo mkdir -p #{god_path}/conf"
|
41
|
+
command echo_cmd "sudo chown -R #{user} #{god_path}"
|
42
42
|
upload_file "god.sh", "#{god_path}/god.sh"
|
43
|
-
|
43
|
+
command echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
|
44
44
|
end
|
45
45
|
|
46
46
|
task :global do
|
47
|
-
|
48
|
-
|
47
|
+
command echo_cmd "sudo mkdir -p #{god_path}/conf"
|
48
|
+
command echo_cmd "sudo chown -R #{user} #{god_path}"
|
49
49
|
upload_file 'global.god', "#{god_path}/global.god"
|
50
|
-
|
50
|
+
command echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -55,13 +55,13 @@ namespace :god do
|
|
55
55
|
desc "#{action.capitalize} God"
|
56
56
|
task action.to_sym do
|
57
57
|
invoke :sudo
|
58
|
-
|
59
|
-
|
58
|
+
command %{echo "-----> #{action.capitalize} God"}
|
59
|
+
command echo_cmd "sudo #{god_service_path}/god #{action}"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
task :log do
|
64
64
|
invoke :sudo
|
65
|
-
|
65
|
+
command %{sudo tail -f #{god_log_path}/god.log -n #{ENV["n"] || 200}}
|
66
66
|
end
|
67
67
|
end
|
data/lib/mina/extras/local.rb
CHANGED
data/lib/mina/extras/methods.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
def mv_config(source, destination)
|
2
|
-
|
2
|
+
command %{mv #{deploy_to}/shared/config/#{source} #{deploy_to}/shared/config/#{destination}}
|
3
3
|
end
|
4
4
|
|
5
5
|
def extra_echo(desc)
|
6
|
-
|
6
|
+
command "echo '--------> #{desc}'"
|
7
7
|
end
|
8
8
|
|
9
9
|
def extra_echo!(desc)
|
10
|
-
|
10
|
+
command "echo '--------> #{desc}'"
|
11
11
|
end
|
12
12
|
|
13
13
|
def scp_file(desc, source, destination)
|
14
|
-
|
14
|
+
on :after_hook do
|
15
15
|
extra_echo("Put #{desc} file to #{destination}")
|
16
16
|
|
17
17
|
command = "scp "
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
|
28
28
|
def upload_shared_file(filename)
|
29
29
|
src = custom_conf_path(filename)
|
30
|
-
|
30
|
+
|
31
31
|
if src
|
32
32
|
upload_template src, "#{deploy_to}/shared/#{filename}"
|
33
33
|
else
|
@@ -37,7 +37,7 @@ end
|
|
37
37
|
|
38
38
|
def upload_file(filename, destination)
|
39
39
|
src = custom_conf_path(filename)
|
40
|
-
|
40
|
+
|
41
41
|
if src
|
42
42
|
upload_template src, destination
|
43
43
|
else
|
@@ -47,15 +47,15 @@ end
|
|
47
47
|
|
48
48
|
def append_template(source, destination)
|
49
49
|
desc = File.basename(destination)
|
50
|
-
|
50
|
+
|
51
51
|
if source =~ /erb$/
|
52
52
|
contents = parse_template(source)
|
53
53
|
else
|
54
54
|
contents = File.read(source)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
extra_echo("Put #{desc} file to #{destination}")
|
58
|
-
|
58
|
+
|
59
59
|
script = <<EOF
|
60
60
|
script=$(cat <<'EOFF'
|
61
61
|
#{contents}
|
@@ -63,22 +63,22 @@ EOFF
|
|
63
63
|
)
|
64
64
|
EOF
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
command %{#{script}}
|
67
|
+
command %{echo "$script" >> #{destination}}
|
68
|
+
command check_exists(destination)
|
69
69
|
end
|
70
70
|
|
71
71
|
def upload_template(source, destination)
|
72
72
|
desc = File.basename(destination)
|
73
|
-
|
73
|
+
|
74
74
|
if source =~ /erb$/
|
75
75
|
contents = parse_template(source)
|
76
76
|
else
|
77
77
|
contents = parse_template(source)
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
extra_echo("Put #{desc} file to #{destination}")
|
81
|
-
|
81
|
+
|
82
82
|
script = <<EOF
|
83
83
|
script=$(cat <<'EOFF'
|
84
84
|
#{contents}
|
@@ -86,20 +86,20 @@ EOFF
|
|
86
86
|
)
|
87
87
|
EOF
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
command %{#{script}}
|
90
|
+
command %{echo "$script" > #{destination}}
|
91
|
+
command check_exists(destination)
|
92
92
|
end
|
93
93
|
|
94
94
|
def upload_default_template(tpl, destination)
|
95
95
|
desc = File.basename(destination)
|
96
|
-
|
96
|
+
|
97
97
|
source = File.join(File.dirname(__FILE__), "templates", "#{tpl}.erb")
|
98
|
-
|
98
|
+
|
99
99
|
contents = parse_template(source)
|
100
|
-
|
100
|
+
|
101
101
|
extra_echo("Put #{desc} file to #{destination}")
|
102
|
-
|
102
|
+
|
103
103
|
script = <<EOF
|
104
104
|
script=$(cat <<'EOFF'
|
105
105
|
#{contents}
|
@@ -107,23 +107,23 @@ EOFF
|
|
107
107
|
)
|
108
108
|
EOF
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
command %{#{script}}
|
111
|
+
command %{echo "$script" > #{destination}}
|
112
|
+
command check_exists(destination)
|
113
113
|
end
|
114
114
|
|
115
115
|
def upload_shared_folder(folder, base)
|
116
|
-
Dir[File.join(folder, "*")].map do |path|
|
116
|
+
Dir[File.join(folder, "*")].map do |path|
|
117
117
|
if File.directory?(path)
|
118
118
|
upload_shared_folder(path)
|
119
119
|
else
|
120
120
|
filename = File.basename(path)
|
121
121
|
shared_folder = path.gsub(base, "").gsub(filename, "").gsub(/\A\//, "").gsub(/\/\Z/, "")
|
122
122
|
des = "#{deploy_to}/shared/#{shared_folder}/#{filename.gsub(/\.erb$/, "")}"
|
123
|
-
upload_template path, des
|
123
|
+
upload_template path, des
|
124
124
|
end
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
end
|
128
128
|
|
129
129
|
def parse_template(file)
|
@@ -163,7 +163,7 @@ def custom_conf?(conf)
|
|
163
163
|
return true
|
164
164
|
end
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
false
|
168
168
|
end
|
169
169
|
|
@@ -174,19 +174,19 @@ def custom_conf_path(conf)
|
|
174
174
|
return file
|
175
175
|
end
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
Dir[File.join(Dir.pwd, "config", "deploy", "shared", "*")].map do |file|
|
179
179
|
filename = File.basename(file)
|
180
180
|
if filename.gsub(/.erb\Z/, "") == conf.to_s
|
181
181
|
return file
|
182
182
|
end
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
false
|
186
186
|
end
|
187
187
|
|
188
|
-
def
|
189
|
-
|
188
|
+
def command_echo(s)
|
189
|
+
command %{echo '#{s}'}
|
190
190
|
end
|
191
191
|
|
192
192
|
def check_file_exist?(file)
|
data/lib/mina/extras/mysql.rb
CHANGED
data/lib/mina/extras/nginx.rb
CHANGED
@@ -19,18 +19,18 @@ namespace :nginx do
|
|
19
19
|
invoke :sudo
|
20
20
|
extra_echo("Nginx: Symlink config file")
|
21
21
|
|
22
|
-
|
23
|
-
#
|
22
|
+
command echo_cmd %{sudo ln -fs "#{deploy_to}/shared/nginx.conf" "#{nginx_conf_path}/#{app!}.conf"}
|
23
|
+
# command check_symlink nginx_conf_path
|
24
24
|
end
|
25
25
|
|
26
26
|
desc "Current nginx config"
|
27
27
|
task :config do
|
28
28
|
invoke :sudo
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
command_echo("#"*80)
|
31
|
+
command_echo("# File: #{nginx_conf_path}/#{app!}.conf")
|
32
|
+
command %{sudo cat "#{nginx_conf_path}/#{app!}.conf"}
|
33
|
+
command_echo("#"*80)
|
34
34
|
end
|
35
35
|
|
36
36
|
%w(stop start restart reload status).each do |action|
|
@@ -38,7 +38,7 @@ namespace :nginx do
|
|
38
38
|
task action.to_sym do
|
39
39
|
invoke :sudo
|
40
40
|
extra_echo("Nginx: #{action.capitalize}")
|
41
|
-
|
41
|
+
command echo_cmd "sudo service nginx #{action}"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/mina/extras/platform.rb
CHANGED
@@ -11,19 +11,19 @@ end
|
|
11
11
|
desc "Roll backs the lates release"
|
12
12
|
task :rollback => :environment do
|
13
13
|
extra_echo!("Rolling back to previous release for instance: #{domain}")
|
14
|
-
|
14
|
+
command %[echo "-----> Rolling back to previous release for instance: #{domain}"]
|
15
15
|
|
16
16
|
# remove latest release folder (active release)
|
17
17
|
extra_echo("Deleting active release: ")
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
command %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1]
|
20
|
+
command %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1 | xargs -I active rm -rf "#{deploy_to}/releases/active"]
|
21
21
|
|
22
22
|
# delete existing sym link and create a new symlink pointing to the previous release
|
23
23
|
extra_echo("Creating new symlink from the previous release: ")
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
command %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1]
|
25
|
+
command %[rm "#{deploy_to}/current"]
|
26
|
+
command %[ls -Art "#{deploy_to}/releases" | sort | tail -n 1 | xargs -I active ln -s "#{deploy_to}/releases/active" "#{deploy_to}/current"]
|
27
27
|
|
28
28
|
invoke :'unicorn:restart'
|
29
29
|
end
|
data/lib/mina/extras/rails.rb
CHANGED
@@ -2,10 +2,10 @@ set_default :log_line, 200
|
|
2
2
|
|
3
3
|
desc "Rails Log"
|
4
4
|
task :log => :environment do
|
5
|
-
|
5
|
+
command echo_cmd("cd #{deploy_to}/current && tail -f log/production.log -n #{ENV["n"] || log_line}")
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Rails Console"
|
9
9
|
task :console => :environment do
|
10
|
-
|
10
|
+
command echo_cmd("cd #{deploy_to}/current && RAILS_ENV=production bundle exec rails c")
|
11
11
|
end
|
data/lib/mina/extras/rainbows.rb
CHANGED
@@ -20,24 +20,24 @@ namespace :rainbows do
|
|
20
20
|
desc "Unicron: startup"
|
21
21
|
task :defaults do
|
22
22
|
invoke :sudo
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
command echo_cmd %{sudo chown root:root /etc/init.d/rainbows-#{app!}}
|
24
|
+
command echo_cmd %{sudo chmod u+x /etc/init.d/rainbows-#{app!}}
|
25
|
+
command echo_cmd "sudo update-rc.d rainbows-#{app!} defaults"
|
26
26
|
end
|
27
27
|
|
28
28
|
task :log do
|
29
|
-
|
29
|
+
command %{tail -f "#{deploy_to!}/#{shared_path}/log/rainbows.log" -n 200}
|
30
30
|
end
|
31
31
|
|
32
32
|
task :err_log do
|
33
|
-
|
33
|
+
command %{tail -f "#{deploy_to!}/#{shared_path}/log/rainbows.error.log" -n 200}
|
34
34
|
end
|
35
35
|
|
36
36
|
desc "Rainbows: Link script files"
|
37
37
|
task :link do
|
38
38
|
invoke :sudo
|
39
39
|
extra_echo("Rainbows: Link script file")
|
40
|
-
|
40
|
+
command echo_cmd %{sudo cp '#{deploy_to}/shared/config/rainbows_init.sh' '/etc/init.d/rainbows-#{app!}'}
|
41
41
|
|
42
42
|
invoke :"rainbows:defaults"
|
43
43
|
end
|
@@ -45,19 +45,19 @@ namespace :rainbows do
|
|
45
45
|
desc "Start rainbows"
|
46
46
|
task :start do
|
47
47
|
extra_echo("Rainbows: Start")
|
48
|
-
|
48
|
+
command echo_cmd "/etc/init.d/rainbows-#{app!} start"
|
49
49
|
end
|
50
50
|
|
51
51
|
desc "Stop rainbows"
|
52
52
|
task :stop do
|
53
53
|
extra_echo("Rainbows: Stop")
|
54
|
-
|
54
|
+
command echo_cmd "/etc/init.d/rainbows-#{app!} stop"
|
55
55
|
end
|
56
56
|
|
57
57
|
desc "Restart rainbows using 'upgrade'"
|
58
58
|
task :restart do
|
59
59
|
extra_echo("Rainbows: Restart")
|
60
|
-
|
60
|
+
command echo_cmd "/etc/init.d/rainbows-#{app!} upgrade"
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
data/lib/mina/extras/redis.rb
CHANGED
data/lib/mina/extras/system.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
task :health do
|
2
|
-
|
2
|
+
command 'ps aux | grep -v grep | grep -v bash | grep -e "bin\/god" -e "unicorn_rails" -e "mongod" -e "nginx" -e "redis" -e "STAT START TIME COMMAND" -e "bash"'
|
3
3
|
end
|
4
4
|
|
5
5
|
task :uptime do
|
6
|
-
|
6
|
+
command 'uptime'
|
7
7
|
end
|
8
8
|
|
9
9
|
task :gp do
|
10
|
-
|
10
|
+
command echo_cmd "ps aux | grep #{ENV["p"]}"
|
11
11
|
end
|
data/lib/mina/extras/ubuntu.rb
CHANGED
@@ -7,57 +7,57 @@ set :platform, :ubuntu
|
|
7
7
|
|
8
8
|
def add_user(u)
|
9
9
|
invoke :sudo
|
10
|
-
|
10
|
+
command "adduser #{u}"
|
11
11
|
end
|
12
12
|
|
13
13
|
namespace :ubuntu do
|
14
|
-
|
14
|
+
|
15
15
|
task :before_check do
|
16
|
-
|
16
|
+
on :before_hook do
|
17
17
|
invoke :"local:check_ssh_key"
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
namespace :remote do
|
22
22
|
task :setup do
|
23
23
|
invoke :sudo
|
24
|
-
|
24
|
+
command echo_cmd %{mkdir -p ~/.ssh}
|
25
25
|
append_template(ssh_pub_key_path, ".ssh/authorized_keys")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
task :add_deploy do
|
29
29
|
invoke :sudo
|
30
30
|
add_user("deploy")
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
command "sudo usermod -a -G www-data deploy"
|
32
|
+
|
33
|
+
command echo_cmd "sudo mkdir -p /home/deploy/.ssh"
|
34
|
+
command echo_cmd "sudo touch /home/deploy/.ssh/authorized_keys"
|
35
35
|
append_template(ssh_pub_key_path, "/home/deploy/.ssh/authorized_keys")
|
36
|
-
|
37
|
-
|
36
|
+
command echo_cmd "sudo chown -R deploy:deploy /home/deploy/.ssh"
|
37
|
+
command echo_cmd "sudo chmod 664 /home/deploy/.ssh/authorized_keys"
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
task :add_ubuntu do
|
41
41
|
invoke :sudo
|
42
42
|
add_user("ubuntu")
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
command echo_cmd "sudo groupadd admin"
|
44
|
+
command echo_cmd "sudo usermod -a -G admin ubuntu"
|
45
|
+
command echo_cmd "sudo mkdir -p /home/ubuntu/.ssh"
|
46
|
+
command echo_cmd "sudo touch /home/ubuntu/.ssh/authorized_keys"
|
47
47
|
append_template(ssh_pub_key_path, "/home/ubuntu/.ssh/authorized_keys")
|
48
|
-
|
49
|
-
|
48
|
+
command echo_cmd "sudo chown -R ubuntu:ubuntu /home/ubuntu/.ssh"
|
49
|
+
command echo_cmd "sudo chmod 664 /home/ubuntu/.ssh/authorized_keys"
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
namespace :locale do
|
54
54
|
task :setup do
|
55
55
|
invoke :sudo
|
56
|
-
|
57
|
-
|
56
|
+
command echo_cmd %{sudo locale-gen en_US en_US.UTF8}
|
57
|
+
command echo_cmd %{sudo sh -c "echo 'LC_ALL=\"en_US.utf8\"' >> /etc/environment"}
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
namespace :install do
|
62
62
|
task :prepare do
|
63
63
|
invoke :"apt:get:update"
|
@@ -66,38 +66,38 @@ namespace :ubuntu do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
task :ruby do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
69
|
+
in_path '/tmp' do
|
70
|
+
command "wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz"
|
71
|
+
command "tar xf ruby-2.3.1.tar.gz"
|
72
|
+
end
|
73
|
+
|
74
|
+
in_path '/tmp/ruby-2.3.1' do
|
75
|
+
command "./configure"
|
76
|
+
command "make"
|
77
|
+
command "sudo make install"
|
78
|
+
command "sudo ln -s /usr/local/bin/ruby /usr/bin/ruby"
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
task :rubygems do
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
in_path '/tmp' do
|
84
|
+
command "wget https://rubygems.org/rubygems/rubygems-2.6.8.tgz"
|
85
|
+
command "tar xf rubygems-2.6.8.tgz"
|
86
86
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
|
88
|
+
in_path '/tmp/rubygems-2.6.8' do
|
89
|
+
command "sudo ruby setup.rb install"
|
90
90
|
end
|
91
|
-
end
|
92
|
-
|
91
|
+
end
|
92
|
+
|
93
93
|
task :www do
|
94
94
|
invoke :sudo
|
95
|
-
|
96
|
-
|
95
|
+
command echo_cmd "sudo mkdir -p /var/www"
|
96
|
+
command echo_cmd "sudo chown -R deploy:www-data /var/www"
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
task :ssh_key do
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
100
|
+
command "ssh-keygen -t rsa"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/mina/extras/unicorn.rb
CHANGED
@@ -22,7 +22,7 @@ namespace :unicorn do
|
|
22
22
|
desc "Unicron: startup"
|
23
23
|
task :defaults do
|
24
24
|
invoke :sudo
|
25
|
-
|
25
|
+
command echo_cmd "sudo update-rc.d unicorn-#{app!} defaults"
|
26
26
|
end
|
27
27
|
|
28
28
|
namespace :god do
|
@@ -32,55 +32,55 @@ namespace :unicorn do
|
|
32
32
|
|
33
33
|
task :link do
|
34
34
|
invoke :sudo
|
35
|
-
|
35
|
+
command echo_cmd %{sudo cp -rf #{deploy_to}/#{shared_path}/unicorn.god #{god_path}/conf/unicorn-#{app!}.god}
|
36
36
|
invoke :"god:restart"
|
37
37
|
end
|
38
38
|
|
39
39
|
task :start do
|
40
40
|
invoke :sudo
|
41
|
-
|
41
|
+
command echo_cmd %{sudo god start unicorn_#{app!}}
|
42
42
|
end
|
43
43
|
|
44
44
|
task :stop do
|
45
45
|
invoke :sudo
|
46
|
-
|
46
|
+
command echo_cmd %{sudo god stop unicorn_#{app!}}
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
task :log do
|
51
|
-
|
51
|
+
command %{tail -f "#{deploy_to!}/#{shared_path}/log/unicorn.log" -n 200}
|
52
52
|
end
|
53
53
|
|
54
54
|
task :err_log do
|
55
|
-
|
55
|
+
command %{tail -f "#{deploy_to!}/#{shared_path}/log/unicorn.error.log" -n 200}
|
56
56
|
end
|
57
57
|
|
58
58
|
desc "Unicorn: Link script files"
|
59
59
|
task :link do
|
60
60
|
invoke :sudo
|
61
61
|
extra_echo("Unicorn: Link script file")
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
command echo_cmd %{sudo cp '#{deploy_to}/shared/unicorn_init.sh' '/etc/init.d/unicorn-#{app!}'}
|
63
|
+
command echo_cmd %{sudo chown #{user!}:#{group!} /etc/init.d/unicorn-#{app!}}
|
64
|
+
command echo_cmd %{sudo chmod u+x /etc/init.d/unicorn-#{app!}}
|
65
65
|
# invoke :"unicorn:defaults"
|
66
66
|
end
|
67
67
|
|
68
68
|
desc "Start unicorn"
|
69
69
|
task :start do
|
70
70
|
extra_echo("Unicorn: Start")
|
71
|
-
|
71
|
+
command echo_cmd "/etc/init.d/unicorn-#{app!} start"
|
72
72
|
end
|
73
73
|
|
74
74
|
desc "Stop unicorn"
|
75
75
|
task :stop do
|
76
76
|
extra_echo("Unicorn: Stop")
|
77
|
-
|
77
|
+
command echo_cmd "/etc/init.d/unicorn-#{app!} stop"
|
78
78
|
end
|
79
79
|
|
80
80
|
desc "Restart unicorn using 'upgrade'"
|
81
81
|
task :restart do
|
82
82
|
extra_echo("Unicorn: Restart")
|
83
|
-
|
83
|
+
command echo_cmd "/etc/init.d/unicorn-#{app!} upgrade"
|
84
84
|
end
|
85
85
|
|
86
86
|
end
|
data/lib/mina/extras/version.rb
CHANGED
data/mina-rails-tools.gemspec
CHANGED
@@ -16,17 +16,17 @@ set :ssh_key_path, "/Users/joey/.ssh/id_rsa"
|
|
16
16
|
|
17
17
|
task :start do
|
18
18
|
invoke :sudo
|
19
|
-
|
19
|
+
command "whoami"
|
20
20
|
invoke :"osx:before_check"
|
21
21
|
invoke :"osx:remote:setup"
|
22
22
|
invoke :"osx:locale:setup"
|
23
23
|
invoke :"osx:install:prepare"
|
24
|
-
mina_cleanup!
|
25
24
|
|
25
|
+
mina_cleanup!
|
26
26
|
clean_commands!
|
27
27
|
|
28
28
|
invoke :user
|
29
|
-
|
29
|
+
command "whoami"
|
30
30
|
invoke :"brew:install:mysql"
|
31
31
|
invoke :"brew:install:redis"
|
32
32
|
invoke :"brew:install:nginx"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "mina/bundler"
|
2
|
+
require "mina/rails"
|
3
|
+
require "mina/git"
|
4
|
+
require "mina/extras"
|
5
|
+
require "mina/extras/nginx"
|
6
|
+
require "mina/extras/unicorn"
|
7
|
+
require "mina/extras/god"
|
8
|
+
|
9
|
+
Dir[File.join(Dir.pwd, "config", "deploy", "*.rb")].each { |f| load f }
|
10
|
+
|
11
|
+
set :user, 'deploy'
|
12
|
+
set :group, "www-data"
|
13
|
+
set :sudoer, "joey"
|
14
|
+
|
15
|
+
set :keep_releases, 5
|
16
|
+
set :domain, '192.168.11.107'
|
17
|
+
set :deploy_to, "/var/www/test"
|
18
|
+
set :shared_paths, ["config/database.yml", "tmp", "log", "pids", "config/application.yml"]
|
19
|
+
set :repository, "git@xxxx:test.git"
|
20
|
+
# set :branch, "master"
|
21
|
+
|
22
|
+
set :app, 'test'
|
23
|
+
|
24
|
+
desc "Deploys the current version to the server."
|
25
|
+
task :deploy => :environment do
|
26
|
+
deploy do
|
27
|
+
invoke :'git:clone'
|
28
|
+
invoke :'deploy:link_shared_paths'
|
29
|
+
invoke :'bundle:install'
|
30
|
+
invoke :'rails:db_create'
|
31
|
+
invoke :'rails:db_migrate'
|
32
|
+
invoke :'rails:assets_precompile'
|
33
|
+
|
34
|
+
to :launch do
|
35
|
+
invoke :'unicorn:restart'
|
36
|
+
end
|
37
|
+
|
38
|
+
invoke :'deploy:cleanup'
|
39
|
+
end
|
40
|
+
end
|
@@ -16,7 +16,7 @@ set :ssh_key_path, "/Users/joey/.ssh/id_rsa"
|
|
16
16
|
|
17
17
|
task :start do
|
18
18
|
invoke :sudo
|
19
|
-
|
19
|
+
command "whoami"
|
20
20
|
invoke :"ubuntu:before_check"
|
21
21
|
invoke :"ubuntu:remote:setup"
|
22
22
|
invoke :"ubuntu:locale:setup"
|
@@ -28,7 +28,7 @@ task :start do
|
|
28
28
|
clean_commands!
|
29
29
|
|
30
30
|
invoke :user
|
31
|
-
|
31
|
+
command "whoami"
|
32
32
|
invoke :"apt:get:mysql"
|
33
33
|
invoke :"apt:get:redis"
|
34
34
|
invoke :"apt:get:nginx"
|
data/samples/ubuntu/prepare.sh
CHANGED
@@ -4,12 +4,14 @@ sudo apt-get install build-essential libssl-dev libreadline-dev
|
|
4
4
|
cd /tmp
|
5
5
|
wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz
|
6
6
|
tar xf ruby-2.2.3.tar.gz
|
7
|
+
cd ruby-2.2.3
|
7
8
|
./configure && make
|
8
9
|
sudo make install
|
9
10
|
sudo ln -s /usr/local/bin/ruby /usr/bin/ruby
|
10
11
|
cd /tmp
|
11
12
|
wget http://rubygems.org/rubygems/rubygems-2.4.8.tgz
|
12
13
|
tar xf rubygems-2.4.8.tgz
|
14
|
+
cd rubygems-2.4.8
|
13
15
|
sudo ruby setup.rb install
|
14
16
|
|
15
17
|
sudo gem source -a http://ruby.taobao.org/
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-rails-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joey Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mina
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '1.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '1.0'
|
55
55
|
description: ''
|
56
56
|
email:
|
57
57
|
- joeyoooooo@gmail.com
|
@@ -59,7 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
62
|
+
- ".gitignore"
|
63
63
|
- Gemfile
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- samples/osx/config/deploy/shared/global.god.erb
|
96
96
|
- samples/osx/config/deploy/shared/god.sh.erb
|
97
97
|
- samples/osx/prepare.sh
|
98
|
+
- samples/rails/config/deploy.rb
|
98
99
|
- samples/ubuntu/config/deploy.rb
|
99
100
|
- samples/ubuntu/config/deploy/shared/global.god.erb
|
100
101
|
- samples/ubuntu/config/deploy/shared/god.sh.erb
|
@@ -110,17 +111,17 @@ require_paths:
|
|
110
111
|
- lib
|
111
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
|
-
- -
|
114
|
+
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
118
|
requirements:
|
118
|
-
- -
|
119
|
+
- - ">="
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.4.
|
124
|
+
rubygems_version: 2.4.5.1
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Extra deploy scripts for rails
|