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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b5242ae48aecf33e80ed2ba1b510cc4ceafa441
4
- data.tar.gz: 7f3f5b31c827d4a5c6bd9455317840ecda4225eb
3
+ metadata.gz: 0b1ec0a24ccf8326ac0f432baee756bf25e0191f
4
+ data.tar.gz: c69caa75b329a4320855f9458a5ff9187a2dddaf
5
5
  SHA512:
6
- metadata.gz: 3b3c616152026bc8f56da7ac4143d00c017ea91390b82b60cb0d2bb21b340582ee4bdc762810a7769cece5fa183ff12a01cfa3843778edcc470c7a2b43fa151c
7
- data.tar.gz: fb0ff6b8dfc7a740fa41a55a18f4e65a539d6211e137f6107659456af62110beefe92cab3c6da023fc7c36efa34accea3491fc6adf0779eed4941b85cc8b7a43
6
+ metadata.gz: 8b7bbfb3051c57118b6302a15ea8a45df6ebd8298686637145f48d83b44f7d1db5144d8d32085e65e3be0cf33cbaf2e53741405f0215f962c1e97a7f4d21ec41
7
+ data.tar.gz: 0d577df6d81c040332d449ca6806c5bd1d7342410723018bff29479aec0479e4ce29cba36290592ed8ce3adfedea69849169c954911f7fe17a883e069ddcaf1f
@@ -1,66 +1,66 @@
1
1
  set_default :apt_source, :us
2
2
 
3
3
  def apt_get(package)
4
- queue echo_cmd "sudo apt-get install #{package} -y"
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
- queue "sudo apt-get update"
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.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
@@ -1,5 +1,5 @@
1
1
  def brew_install(package)
2
- queue echo_cmd "sudo brew install #{package} -y"
2
+ command echo_cmd "sudo brew install #{package} -y"
3
3
  end
4
4
 
5
5
 
@@ -27,10 +27,10 @@ task :setup => :environment do
27
27
  end
28
28
  end
29
29
 
30
- queue %{echo "-----> (!!!) You now need to run 'mina sudoer_setup' to run the parts that require sudoer user (!!!)"}
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
- # queue %{echo "-----> (!!!) You now need to run 'mina sudoer_setup' to run the parts that require sudoer user (!!!)"}
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
- queue echo_cmd %{mkdir -p "#{deploy_to}/shared/#{dir}"}
60
+ command echo_cmd %{mkdir -p "#{deploy_to}/shared/#{dir}"}
61
61
  end
62
62
  end
63
63
 
@@ -1,5 +1,5 @@
1
1
  def gem_install(package, options=nil)
2
- queue echo_cmd "sudo gem install #{package} #{options} --no-rdoc --no-ri"
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
- queue echo_cmd "sudo gem source -a http://ruby.taobao.org/"
15
- queue echo_cmd "sudo gem source -r https://rubygems.org/"
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
- queue echo_cmd "sudo gem source"
20
+ command echo_cmd "sudo gem source"
21
21
  end
22
22
  end
23
23
 
@@ -10,44 +10,44 @@ set :use_god, true
10
10
  namespace :god do
11
11
 
12
12
  task :setup do
13
- queue echo_cmd "sudo mkdir -p #{god_path}/conf"
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
- queue echo_cmd %{sudo rm -rf "#{god_service_path}/god"}
19
- queue echo_cmd "sudo mkdir -p #{god_path}/conf"
20
- queue echo_cmd "sudo chown -R #{user} #{god_path}"
21
- queue echo_cmd %{sudo cp "#{god_path}/god.sh" "#{god_service_path}/god"}
22
- queue echo_cmd %{sudo chown #{god_user}:#{god_group} "#{god_service_path}/god"}
23
- queue echo_cmd %{sudo chmod +x "#{god_service_path}/god"}
24
- queue echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
25
- queue echo_cmd "sudo update-rc.d god defaults"
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
- queue echo_cmd "sudo chown -R #{user} #{god_path}"
29
+ command echo_cmd "sudo chown -R #{user} #{god_path}"
30
30
  end
31
31
 
32
32
  task :set_permission do
33
- queue echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
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
- queue echo_cmd "sudo mkdir -p #{god_path}/conf"
41
- queue echo_cmd "sudo chown -R #{user} #{god_path}"
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
- queue echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
43
+ command echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
44
44
  end
45
45
 
46
46
  task :global do
47
- queue echo_cmd "sudo mkdir -p #{god_path}/conf"
48
- queue echo_cmd "sudo chown -R #{user} #{god_path}"
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
- queue echo_cmd "sudo chown -R #{god_user}:#{god_group} #{god_path}"
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
- queue %{echo "-----> #{action.capitalize} God"}
59
- queue echo_cmd "sudo #{god_service_path}/god #{action}"
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
- queue %{sudo tail -f #{god_log_path}/god.log -n #{ENV["n"] || 200}}
65
+ command %{sudo tail -f #{god_log_path}/god.log -n #{ENV["n"] || 200}}
66
66
  end
67
67
  end
@@ -6,7 +6,7 @@ namespace :local do
6
6
  check_key = check_file_exist?(ssh_pub_key_path!) && check_file_exist?(ssh_key_path!)
7
7
 
8
8
  unless check_key
9
- queue "ssh-keygen -t rsa"
9
+ command "ssh-keygen -t rsa"
10
10
  end
11
11
  end
12
12
  end
@@ -1,17 +1,17 @@
1
1
  def mv_config(source, destination)
2
- queue %{mv #{deploy_to}/shared/config/#{source} #{deploy_to}/shared/config/#{destination}}
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
- queue "echo '--------> #{desc}'"
6
+ command "echo '--------> #{desc}'"
7
7
  end
8
8
 
9
9
  def extra_echo!(desc)
10
- queue! "echo '--------> #{desc}'"
10
+ command "echo '--------> #{desc}'"
11
11
  end
12
12
 
13
13
  def scp_file(desc, source, destination)
14
- to :after_hook do
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
- queue %{#{script}}
67
- queue %{echo "$script" >> #{destination}}
68
- queue check_exists(destination)
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
- queue %{#{script}}
90
- queue %{echo "$script" > #{destination}}
91
- queue check_exists(destination)
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
- queue %{#{script}}
111
- queue %{echo "$script" > #{destination}}
112
- queue check_exists(destination)
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 queue_echo(s)
189
- queue %{echo '#{s}'}
188
+ def command_echo(s)
189
+ command %{echo '#{s}'}
190
190
  end
191
191
 
192
192
  def check_file_exist?(file)
@@ -6,7 +6,7 @@ namespace :mysql do
6
6
  desc "Connect to mysql"
7
7
  task :connect do
8
8
  extra_echo "Mysql: connect"
9
- queue "mysql -u #{mysql_user} #{mysql_pass ? "-p" : ""}"
9
+ command "mysql -u #{mysql_user} #{mysql_pass ? "-p" : ""}"
10
10
  end
11
11
 
12
12
  end
@@ -19,18 +19,18 @@ namespace :nginx do
19
19
  invoke :sudo
20
20
  extra_echo("Nginx: Symlink config file")
21
21
 
22
- queue echo_cmd %{sudo ln -fs "#{deploy_to}/shared/nginx.conf" "#{nginx_conf_path}/#{app!}.conf"}
23
- # queue check_symlink nginx_conf_path
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
- queue_echo("#"*80)
31
- queue_echo("# File: #{nginx_conf_path}/#{app!}.conf")
32
- queue %{sudo cat "#{nginx_conf_path}/#{app!}.conf"}
33
- queue_echo("#"*80)
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
- queue echo_cmd "sudo service nginx #{action}"
41
+ command echo_cmd "sudo service nginx #{action}"
42
42
  end
43
43
  end
44
44
  end
@@ -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
- queue! %[echo "-----> Rolling back to previous release for instance: #{domain}"]
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
- queue %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1]
20
- queue! %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1 | xargs -I active rm -rf "#{deploy_to}/releases/active"]
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
- queue %[ls "#{deploy_to}/releases" -Art | sort | tail -n 1]
25
- queue! %[rm "#{deploy_to}/current"]
26
- queue! %[ls -Art "#{deploy_to}/releases" | sort | tail -n 1 | xargs -I active ln -s "#{deploy_to}/releases/active" "#{deploy_to}/current"]
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
@@ -2,10 +2,10 @@ set_default :log_line, 200
2
2
 
3
3
  desc "Rails Log"
4
4
  task :log => :environment do
5
- queue echo_cmd("cd #{deploy_to}/current && tail -f log/production.log -n #{ENV["n"] || log_line}")
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
- queue echo_cmd("cd #{deploy_to}/current && RAILS_ENV=production bundle exec rails c")
10
+ command echo_cmd("cd #{deploy_to}/current && RAILS_ENV=production bundle exec rails c")
11
11
  end
@@ -20,24 +20,24 @@ namespace :rainbows do
20
20
  desc "Unicron: startup"
21
21
  task :defaults do
22
22
  invoke :sudo
23
- queue echo_cmd %{sudo chown root:root /etc/init.d/rainbows-#{app!}}
24
- queue echo_cmd %{sudo chmod u+x /etc/init.d/rainbows-#{app!}}
25
- queue echo_cmd "sudo update-rc.d rainbows-#{app!} defaults"
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
- queue %{tail -f "#{deploy_to!}/#{shared_path}/log/rainbows.log" -n 200}
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
- queue %{tail -f "#{deploy_to!}/#{shared_path}/log/rainbows.error.log" -n 200}
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
- queue echo_cmd %{sudo cp '#{deploy_to}/shared/config/rainbows_init.sh' '/etc/init.d/rainbows-#{app!}'}
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
- queue echo_cmd "/etc/init.d/rainbows-#{app!} start"
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
- queue echo_cmd "/etc/init.d/rainbows-#{app!} stop"
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
- queue echo_cmd "/etc/init.d/rainbows-#{app!} upgrade"
60
+ command echo_cmd "/etc/init.d/rainbows-#{app!} upgrade"
61
61
  end
62
62
 
63
63
  end
@@ -3,7 +3,7 @@ namespace :redis do
3
3
  desc "Connect to redis"
4
4
  task :connect do
5
5
  extra_echo "Redis: connect"
6
- queue "redis-cli"
6
+ command "redis-cli"
7
7
  end
8
8
 
9
9
  end
@@ -1,11 +1,11 @@
1
1
  task :health do
2
- queue '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"'
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
- queue 'uptime'
6
+ command 'uptime'
7
7
  end
8
8
 
9
9
  task :gp do
10
- queue echo_cmd "ps aux | grep #{ENV["p"]}"
10
+ command echo_cmd "ps aux | grep #{ENV["p"]}"
11
11
  end
@@ -7,57 +7,57 @@ set :platform, :ubuntu
7
7
 
8
8
  def add_user(u)
9
9
  invoke :sudo
10
- queue "adduser #{u}"
10
+ command "adduser #{u}"
11
11
  end
12
12
 
13
13
  namespace :ubuntu do
14
-
14
+
15
15
  task :before_check do
16
- to :before_hook do
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
- queue echo_cmd %{mkdir -p ~/.ssh}
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
- queue "sudo usermod -a -G www-data deploy"
32
-
33
- queue echo_cmd "sudo mkdir -p /home/deploy/.ssh"
34
- queue echo_cmd "sudo touch /home/deploy/.ssh/authorized_keys"
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
- queue echo_cmd "sudo chown -R deploy:deploy /home/deploy/.ssh"
37
- queue echo_cmd "sudo chmod 664 /home/deploy/.ssh/authorized_keys"
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
- queue echo_cmd "sudo groupadd admin"
44
- queue echo_cmd "sudo usermod -a -G admin ubuntu"
45
- queue echo_cmd "sudo mkdir -p /home/ubuntu/.ssh"
46
- queue echo_cmd "sudo touch /home/ubuntu/.ssh/authorized_keys"
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
- queue echo_cmd "sudo chown -R ubuntu:ubuntu /home/ubuntu/.ssh"
49
- queue echo_cmd "sudo chmod 664 /home/ubuntu/.ssh/authorized_keys"
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
- queue echo_cmd %{sudo locale-gen en_US en_US.UTF8}
57
- queue echo_cmd %{sudo sh -c "echo 'LC_ALL=\"en_US.utf8\"' >> /etc/environment"}
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
- in_directory '/tmp' do
70
- queue "wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz"
71
- queue "tar xf ruby-2.2.3.tar.gz"
72
- end
73
-
74
- in_directory '/tmp/ruby-2.2.3' do
75
- queue "./configure"
76
- queue "make"
77
- queue "sudo make install"
78
- queue "sudo ln -s /usr/local/bin/ruby /usr/bin/ruby"
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
- in_directory '/tmp' do
84
- queue "wget http://rubygems.org/rubygems/rubygems-2.4.8.tgz"
85
- queue "tar xf rubygems-2.4.8.tgz"
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
- in_directory '/tmp/rubygems-2.4.8' do
89
- queue "sudo ruby setup.rb install"
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
- queue echo_cmd "sudo mkdir -p /var/www"
96
- queue echo_cmd "sudo chown -R deploy:www-data /var/www"
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
- queue "ssh-keygen -t rsa"
101
- end
102
- end
103
- end
100
+ command "ssh-keygen -t rsa"
101
+ end
102
+ end
103
+ end
@@ -22,7 +22,7 @@ namespace :unicorn do
22
22
  desc "Unicron: startup"
23
23
  task :defaults do
24
24
  invoke :sudo
25
- queue echo_cmd "sudo update-rc.d unicorn-#{app!} defaults"
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
- queue echo_cmd %{sudo cp -rf #{deploy_to}/#{shared_path}/unicorn.god #{god_path}/conf/unicorn-#{app!}.god}
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
- queue echo_cmd %{sudo god start unicorn_#{app!}}
41
+ command echo_cmd %{sudo god start unicorn_#{app!}}
42
42
  end
43
43
 
44
44
  task :stop do
45
45
  invoke :sudo
46
- queue echo_cmd %{sudo god stop unicorn_#{app!}}
46
+ command echo_cmd %{sudo god stop unicorn_#{app!}}
47
47
  end
48
48
  end
49
49
 
50
50
  task :log do
51
- queue %{tail -f "#{deploy_to!}/#{shared_path}/log/unicorn.log" -n 200}
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
- queue %{tail -f "#{deploy_to!}/#{shared_path}/log/unicorn.error.log" -n 200}
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
- queue echo_cmd %{sudo cp '#{deploy_to}/shared/unicorn_init.sh' '/etc/init.d/unicorn-#{app!}'}
63
- queue echo_cmd %{sudo chown #{user!}:#{group!} /etc/init.d/unicorn-#{app!}}
64
- queue echo_cmd %{sudo chmod u+x /etc/init.d/unicorn-#{app!}}
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
- queue echo_cmd "/etc/init.d/unicorn-#{app!} start"
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
- queue echo_cmd "/etc/init.d/unicorn-#{app!} stop"
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
- queue echo_cmd "/etc/init.d/unicorn-#{app!} upgrade"
83
+ command echo_cmd "/etc/init.d/unicorn-#{app!} upgrade"
84
84
  end
85
85
 
86
86
  end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Extras
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.10"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "mina", "0.3.7"
32
+ spec.add_development_dependency "mina", "~> 1.0"
33
33
  end
@@ -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
- queue "whoami"
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
- queue "whoami"
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
- queue "whoami"
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
- queue "whoami"
31
+ command "whoami"
32
32
  invoke :"apt:get:mysql"
33
33
  invoke :"apt:get:redis"
34
34
  invoke :"apt:get:nginx"
@@ -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.0
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: 2015-10-10 00:00:00.000000000 Z
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.3.7
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.3.7
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.8
124
+ rubygems_version: 2.4.5.1
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: Extra deploy scripts for rails