mina-rails-tools 0.2.2 → 0.2.3

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: e6cc834f968cf4318442fb6e962ab0a57751da78
4
- data.tar.gz: 7c5ee6d964ee90802fc568e7201e7895f30576be
3
+ metadata.gz: f44e56fe401159e89c228b0cb0839d8dc188360d
4
+ data.tar.gz: fdd699e445827faa4de26aa1bf99b29e6e1d04bb
5
5
  SHA512:
6
- metadata.gz: 2d6c717339be2b0c6fd6629200d1a2f3eca872366539c4307559085438a3b1828b6ac1b8390965e4539fc549147a57e5dc24f3a612db950a6d7978c58b80f52b
7
- data.tar.gz: bca7a36e46266bc1c54ae82401681dbf012cae1cfaded987544cc19f79ed32181cc337432fa85981e19103dec24c1545437f82dc585dad947b74af67171e75a9
6
+ metadata.gz: bc7aca8526ae6e0346b8a0736fd0224452987b001c9f06ac593499e9a53f3146c7294de2cdcafd6bfa4aaba434cffc1d0a16fb49cab9b1098d1ec952f913c135
7
+ data.tar.gz: 2ea1483ab697a428a85606033554b7c884d091f4c26557816f3f9bd8c0115c6491416c333e4ab5a643f6106c09d743e8fea6950b7ee19a5ac026018b754dad28
@@ -4,13 +4,11 @@ set :sudoer, "root"
4
4
  task :sudo do
5
5
  # set :user, sudoer
6
6
  set :sudo, true
7
- # set :term_mode, :system
8
7
  end
9
8
 
10
9
  task :user do
11
10
  # set :user, user
12
11
  set :sudo, false
13
- # set :term_mode, :system
14
12
  end
15
13
 
16
14
  task :setup => :environment do
@@ -19,10 +17,10 @@ task :setup => :environment do
19
17
 
20
18
  invoke :"nginx:upload"
21
19
 
22
- if use_unicorn
20
+ if fetch(:use_unicorn)
23
21
  invoke :'unicorn:upload'
24
22
 
25
- if use_god
23
+ if fetch(:use_god)
26
24
  invoke :'unicorn:god:upload'
27
25
  end
28
26
  end
@@ -41,10 +39,10 @@ task :sudoer_setup do
41
39
  invoke :'nginx:link'
42
40
  invoke :'nginx:restart'
43
41
 
44
- if use_unicorn
42
+ if fetch(:use_unicorn)
45
43
  invoke :'unicorn:link'
46
44
 
47
- if use_god
45
+ if fetch(:use_god)
48
46
  invoke :'unicorn:god:link'
49
47
  end
50
48
  end
@@ -52,12 +50,14 @@ end
52
50
 
53
51
  namespace :extra do
54
52
  task :create_shared_paths do
55
- folders = shared_paths.map do |path|
56
- path.gsub(/\/\S+\.\S+\Z/, "")
57
- end.uniq
58
-
59
- folders.map do |dir|
60
- command %{mkdir -p "#{fetch(:deploy_to)}/shared/#{dir}"}
53
+ if fetch(:shared_paths)
54
+ folders = fetch(:shared_paths).map do |path|
55
+ path.gsub(/\/\S+\.\S+\Z/, "")
56
+ end.uniq
57
+
58
+ folders.map do |dir|
59
+ command %{mkdir -p "#{fetch(:deploy_to)}/shared/#{dir}"}
60
+ end
61
61
  end
62
62
  end
63
63
 
@@ -71,7 +71,7 @@ namespace :extra do
71
71
  upload_shared_folder(path, base)
72
72
  end
73
73
 
74
- base = File.join(Dir.pwd, "config", "deploy", "#{server}")
74
+ base = File.join(Dir.pwd, "config", "deploy", "#{fetch(:server)}")
75
75
 
76
76
  Dir[File.join(base, "*")].map do |path|
77
77
  # File.directory?
@@ -88,7 +88,7 @@ module Mina
88
88
  module SshHelpers
89
89
  def ssh_command
90
90
  args = domain!
91
- args = if settings[:sudo] && sudoer?
91
+ args = if settings[:sudo] && fetch(:sudoer)
92
92
  "#{sudoer}@#{args}"
93
93
  elsif user?
94
94
  "#{user}@#{args}"
@@ -102,6 +102,32 @@ module Mina
102
102
  end
103
103
 
104
104
 
105
+ module Mina
106
+ module Backend
107
+ class Remote
108
+
109
+ def ssh
110
+ ensure!(:domain)
111
+ args = fetch(:domain)
112
+ p fetch(:sudo), fetch(:sudoer)
113
+ if fetch(:sudo) && fetch(:sudoer)
114
+ args = "#{fetch(:sudoer)}@#{fetch(:domain)}" if set?(:user)
115
+ else
116
+ args = "#{fetch(:user)}@#{fetch(:domain)}" if set?(:user)
117
+ end
118
+ args += " -i #{fetch(:identity_file)}" if set?(:identity_file)
119
+ args += " -p #{fetch(:port)}" if set?(:port)
120
+ args += ' -A' if set?(:forward_agent)
121
+ args += " #{fetch(:ssh_options)}" if set?(:ssh_options)
122
+ args += ' -tt'
123
+ "ssh #{args}"
124
+ end
125
+
126
+ end
127
+ end
128
+ end
129
+
130
+
105
131
  module Mina
106
132
  module Helpers
107
133
  def clean_commands!
@@ -10,58 +10,58 @@ set :use_god, true
10
10
  namespace :god do
11
11
 
12
12
  task :setup do
13
- command "sudo mkdir -p #{god_path}/conf"
13
+ command "sudo mkdir -p #{fetch(:god_path)}/conf"
14
14
  end
15
-
15
+
16
16
  task :link do
17
17
  extra_echo "Relocate god script file"
18
- command %{sudo rm -rf "#{god_service_path}/god"}
19
- command "sudo mkdir -p #{god_path}/conf"
20
- command "sudo chown -R #{user} #{god_path}"
21
- command %{sudo cp "#{god_path}/god.sh" "#{god_service_path}/god"}
22
- command %{sudo chown #{god_user}:#{god_group} "#{god_service_path}/god"}
23
- command %{sudo chmod +x "#{god_service_path}/god"}
24
- command "sudo chown -R #{god_user}:#{god_group} #{god_path}"
18
+ command %{sudo rm -rf "#{fetch(:god_service_path)}/god"}
19
+ command "sudo mkdir -p #{fetch(:god_path)}/conf"
20
+ command "sudo chown -R #{user} #{fetch(:god_path)}"
21
+ command %{sudo cp "#{fetch(:god_path)}/god.sh" "#{fetch(:god_service_path)}/god"}
22
+ command %{sudo chown #{god_user}:#{god_group} "#{fetch(:god_service_path)}/god"}
23
+ command %{sudo chmod +x "#{fetch(:god_service_path)}/god"}
24
+ command "sudo chown -R #{god_user}:#{god_group} #{fetch(:god_path)}"
25
25
  command "sudo update-rc.d god defaults"
26
26
  end
27
-
27
+
28
28
  task :tmp_add_permission do
29
- command "sudo chown -R #{user} #{god_path}"
29
+ command "sudo chown -R #{user} #{fetch(:god_path)}"
30
30
  end
31
-
31
+
32
32
  task :set_permission do
33
- command "sudo chown -R #{god_user}:#{god_group} #{god_path}"
33
+ command "sudo chown -R #{god_user}:#{god_group} #{fetch(: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
- command "sudo mkdir -p #{god_path}/conf"
41
- command "sudo chown -R #{user} #{god_path}"
42
- upload_file "god.sh", "#{god_path}/god.sh"
43
- command "sudo chown -R #{god_user}:#{god_group} #{god_path}"
40
+ command "sudo mkdir -p #{fetch(:god_path)}/conf"
41
+ command "sudo chown -R #{user} #{fetch(:god_path)}"
42
+ upload_file "god.sh", "#{fetch(:god_path)}/god.sh"
43
+ command "sudo chown -R #{god_user}:#{god_group} #{fetch(:god_path)}"
44
44
  end
45
45
 
46
46
  task :global do
47
- command "sudo mkdir -p #{god_path}/conf"
48
- command "sudo chown -R #{user} #{god_path}"
49
- upload_file 'global.god', "#{god_path}/global.god"
50
- command "sudo chown -R #{god_user}:#{god_group} #{god_path}"
51
- end
47
+ command "sudo mkdir -p #{fetch(:god_path)}/conf"
48
+ command "sudo chown -R #{user} #{fetch(:god_path)}"
49
+ upload_file 'global.god', "#{fetch(:god_path)}/global.god"
50
+ command "sudo chown -R #{god_user}:#{god_group} #{fetch(:god_path)}"
51
+ end
52
52
  end
53
-
53
+
54
54
  %w(stop start restart status).each do |action|
55
55
  desc "#{action.capitalize} God"
56
56
  task action.to_sym do
57
57
  invoke :sudo
58
58
  command %{echo "-----> #{action.capitalize} God"}
59
- command "sudo #{god_service_path}/god #{action}"
59
+ command "sudo #{fetch(: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
- end
67
+ end
@@ -157,7 +157,7 @@ def check_symlink(destination)
157
157
  end
158
158
 
159
159
  def custom_conf?(conf)
160
- Dir[File.join(Dir.pwd, "config", "deploy", "#{server}", "*")].map do |file|
160
+ Dir[File.join(Dir.pwd, "config", "deploy", "#{fetch(:server)}", "*")].map do |file|
161
161
  filename = File.basename(file)
162
162
  if filename.gsub(/.erb\Z/, "") == conf.to_s
163
163
  return true
@@ -168,7 +168,7 @@ def custom_conf?(conf)
168
168
  end
169
169
 
170
170
  def custom_conf_path(conf)
171
- Dir[File.join(Dir.pwd, "config", "deploy", "#{server}", "*")].map do |file|
171
+ Dir[File.join(Dir.pwd, "config", "deploy", "#{fetch(:server)}", "*")].map do |file|
172
172
  filename = File.basename(file)
173
173
  if filename.gsub(/.erb\Z/, "") == conf.to_s
174
174
  return file
@@ -1,22 +1,22 @@
1
1
  require "mina/extras"
2
2
 
3
3
  namespace :rainbows do
4
-
4
+
5
5
  desc "Rainbows: Parses config file and uploads it to server"
6
6
  task :upload => [:'upload:config', :'upload:script']
7
-
7
+
8
8
  namespace :upload do
9
9
  desc "Parses Rainbows config file and uploads it to server"
10
10
  task :config do
11
11
  upload_shared_file("rainbows.rb")
12
12
  end
13
-
13
+
14
14
  desc "Parses Rainbows control script file and uploads it to server"
15
15
  task :script do
16
16
  upload_shared_file("rainbows_init.sh")
17
17
  end
18
18
  end
19
-
19
+
20
20
  desc "Unicron: startup"
21
21
  task :defaults do
22
22
  invoke :sudo
@@ -24,13 +24,13 @@ namespace :rainbows do
24
24
  command %{sudo chmod u+x /etc/init.d/rainbows-#{fetch(:app)}}
25
25
  command "sudo update-rc.d rainbows-#{fetch(:app)} defaults"
26
26
  end
27
-
27
+
28
28
  task :log do
29
- command %{tail -f "#{fetch(:deploy_to)}/#{shared_path}/log/rainbows.log" -n 200}
29
+ command %{tail -f "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log/rainbows.log" -n 200}
30
30
  end
31
-
31
+
32
32
  task :err_log do
33
- command %{tail -f "#{fetch(:deploy_to)}/#{shared_path}/log/rainbows.error.log" -n 200}
33
+ command %{tail -f "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log/rainbows.error.log" -n 200}
34
34
  end
35
35
 
36
36
  desc "Rainbows: Link script files"
@@ -38,7 +38,7 @@ namespace :rainbows do
38
38
  invoke :sudo
39
39
  extra_echo("Rainbows: Link script file")
40
40
  command %{sudo cp '#{fetch(:deploy_to)}/shared/config/rainbows_init.sh' '/etc/init.d/rainbows-#{fetch(:app)}'}
41
-
41
+
42
42
  invoke :"rainbows:defaults"
43
43
  end
44
44
 
@@ -1,10 +1,10 @@
1
1
  # http://unicorn.bogomips.org/SIGNALS.html
2
2
 
3
3
  rails_env = "production"
4
- rails_root = "<%= "#{fetch(:deploy_to)}/#{current_path!}" %>"
5
- shared_root = "<%= "#{fetch(:deploy_to)}/#{shared_path!}" %>"
4
+ rails_root = "<%= "#{fetch(:deploy_to)}/#{fetch(:current_path)}" %>"
5
+ shared_root = "<%= "#{fetch(:deploy_to)}/#{fetch(:shared_path)}" %>"
6
6
  config = "#{shared_root}/unicorn.rb"
7
- unicorn_pid = "<%= "#{fetch(:deploy_to)}/#{shared_path!}/pids/unicorn.pid" %>"
7
+ unicorn_pid = "<%= "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/pids/unicorn.pid" %>"
8
8
 
9
9
  # God.pid_file_directory = File.join("<%= fetch(:deploy_to) %>", "shared", "pids")
10
10
  God.watch do |w|
@@ -24,8 +24,8 @@ God.watch do |w|
24
24
  # w.pid_file = "#{rails_root}/tmp/pids/unicorn.pid"
25
25
  w.pid_file = unicorn_pid
26
26
 
27
- w.uid = "<%= user! %>"
28
- w.gid = "<%= group! %>"
27
+ w.uid = "<%= fetch(:user) %>"
28
+ w.gid = "<%= fetch(:group) %>"
29
29
 
30
30
  w.behavior(:clean_pid_file)
31
31
 
@@ -60,10 +60,10 @@ God.watch do |w|
60
60
  c.retry_within = 2.hours
61
61
  end
62
62
  end
63
-
63
+
64
64
  # w.transition(:up, :start) do |on|
65
65
  # on.condition(:process_exits) do |c|
66
66
  # c.notify = 'me'
67
67
  # end
68
68
  # end
69
- end
69
+ end
@@ -1,13 +1,13 @@
1
- rails_root = "<%= "#{fetch(:deploy_to)}/#{current_path!}" %>"
2
- rails_env = "<%= rails_env || "production" %>"
3
- pid_file = "<%= "#{fetch(:deploy_to)}/#{shared_path}" %>/pids/unicorn.pid"
1
+ rails_root = "<%= "#{fetch(:deploy_to)}/current" %>"
2
+ rails_env = "<%= fetch(:rails_env) || "production" %>"
3
+ pid_file = "<%= "#{fetch(:deploy_to)}/shared" %>/pids/unicorn.pid"
4
4
  socket_file= "/tmp/unicorn.<%= fetch(:app) %>.socket"
5
- log_file = "<%= "#{fetch(:deploy_to)}/#{shared_path}" %>/log/unicorn.log"
6
- err_log = "<%= "#{fetch(:deploy_to)}/#{shared_path}" %>/log/unicorn.error.log"
5
+ log_file = "<%= "#{fetch(:deploy_to)}/shared" %>/log/unicorn.log"
6
+ err_log = "<%= "#{fetch(:deploy_to)}/shared" %>/log/unicorn.error.log"
7
7
  old_pid = pid_file + '.oldbin'
8
8
 
9
9
  timeout 60
10
- worker_processes <%= unicorn_workers || 2 %>
10
+ worker_processes <%= fetch(:unicorn_workers) || 2 %>
11
11
 
12
12
  # Listen on a Unix data socket
13
13
  listen socket_file, :backlog => 2048
@@ -4,12 +4,12 @@ set -e
4
4
  AS_USER=deploy
5
5
  TIMEOUT=60
6
6
  APP_ROOT="<%= "#{fetch(:deploy_to)}" %>"
7
- PID_PATH="<%= "#{fetch(:deploy_to)}/#{shared_path!}/pids" %>"
7
+ PID_PATH="<%= "#{fetch(:deploy_to)}/shared/pids" %>"
8
8
  PID="$PID_PATH/unicorn.pid"
9
9
  ENVIRONMENT="<%= fetch(:rails_env) || "production" %>"
10
- CONFIG="$APP_ROOT/<%= "#{shared_path!}/unicorn.rb" %>"
10
+ CONFIG="$APP_ROOT/shared/unicorn.rb"
11
11
  UARGS="-D -c $CONFIG -E $ENVIRONMENT"
12
- CMD="cd $APP_ROOT/<%= current_path! %> && bundle exec unicorn_rails $UARGS"
12
+ CMD="cd $APP_ROOT/current && bundle exec unicorn_rails $UARGS"
13
13
  action="$1"
14
14
  #set -u
15
15
 
@@ -32,7 +32,7 @@ namespace :unicorn do
32
32
 
33
33
  task :link do
34
34
  invoke :sudo
35
- command %{sudo cp -rf #{fetch(:deploy_to)}/#{shared_path}/unicorn.god #{god_path}/conf/unicorn-#{fetch(:app)}.god}
35
+ command %{sudo cp -rf #{fetch(:deploy_to)}/#{fetch(:shared_path)}/unicorn.god #{fetch(:god_path)}/conf/unicorn-#{fetch(:app)}.god}
36
36
  invoke :"god:restart"
37
37
  end
38
38
 
@@ -48,11 +48,11 @@ namespace :unicorn do
48
48
  end
49
49
 
50
50
  task :log do
51
- command %{tail -f "#{fetch(:deploy_to)}/#{shared_path}/log/unicorn.log" -n 200}
51
+ command %{tail -f "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log/unicorn.log" -n 200}
52
52
  end
53
53
 
54
54
  task :err_log do
55
- command %{tail -f "#{fetch(:deploy_to)}/#{shared_path}/log/unicorn.error.log" -n 200}
55
+ command %{tail -f "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log/unicorn.error.log" -n 200}
56
56
  end
57
57
 
58
58
  desc "Unicorn: Link script files"
@@ -60,7 +60,7 @@ namespace :unicorn do
60
60
  invoke :sudo
61
61
  extra_echo("Unicorn: Link script file")
62
62
  command %{sudo cp '#{fetch(:deploy_to)}/shared/unicorn_init.sh' '/etc/init.d/unicorn-#{fetch(:app)}'}
63
- command %{sudo chown #{user!}:#{group!} /etc/init.d/unicorn-#{fetch(:app)}}
63
+ command %{sudo chown #{fetch(:user)}:#{fetch(:group)} /etc/init.d/unicorn-#{fetch(:app)}}
64
64
  command %{sudo chmod u+x /etc/init.d/unicorn-#{fetch(:app)}}
65
65
  # invoke :"unicorn:defaults"
66
66
  end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Extras
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-rails-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Lin