capistrano-unicorn-nginx 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e038ef42790b2e2e9fdbc34f37ac6d4b44e1f4b
4
- data.tar.gz: 7180b47e77e78edc458a79911acc901df9a95a6e
3
+ metadata.gz: 7b24ca75112ef51965b402453911b78ad2464cb7
4
+ data.tar.gz: dcf24a353ca4264baeed850c4869b29867ce4b81
5
5
  SHA512:
6
- metadata.gz: f39f6cbd00235af5642493388123b78b084499076f8ca23f00ab2b08a0279211cc0a3ade952375fda65c74ec4bb8066dc09921e0b3f2ed847d41d7dd559c659f
7
- data.tar.gz: 89ede75ee9776a58a9f0749764b888e04baea723e0b9174a804ec0a26e8f504b1674d02ff562dc09ba21c04ebd9b25fbfa1ade6fa2b180d0ef30fab8e034daed
6
+ metadata.gz: 9960a5da13b29a0be460ffc64b58b05344b129646771972258f4174a274ff317425d92ecd9ae5ded81922bf50a4180ec9e2ebc13537b1d394f28f6ac7aea55e2
7
+ data.tar.gz: 3f67ac584a2ac65d6b85557b36b1ecfe3305405389935e61aba1b9267228a65489675bcd012c8d7d1a8fc35fc21ab293df8cd99b8c0102f4cab35b12243b5787
@@ -1,3 +1,6 @@
1
+ ### v1.0.2, 2014-03-30
2
+ - add `sudo_upload!` helper method for easier uploads
3
+ - improve the way how templates are handled
1
4
  ### v1.0.1, 2014-03-30
2
5
  - refactor all unicorn and nginx paths to separate modules
3
6
  - speed up `nginx:setup_ssl` task
@@ -2,10 +2,6 @@ module Capistrano
2
2
  module DSL
3
3
  module NginxPaths
4
4
 
5
- def nginx_config_tmp_file
6
- "#{fetch(:tmp_dir)}/#{fetch(:nginx_config_name)}"
7
- end
8
-
9
5
  def nginx_sites_available_file
10
6
  "/etc/nginx/sites-available/#{fetch(:nginx_config_name)}"
11
7
  end
@@ -2,10 +2,6 @@ module Capistrano
2
2
  module DSL
3
3
  module UnicornPaths
4
4
 
5
- def unicorn_initd_tmp_file
6
- "#{fetch(:tmp_dir)}/#{fetch(:unicorn_service)}"
7
- end
8
-
9
5
  def unicorn_initd_file
10
6
  "/etc/init.d/#{fetch(:unicorn_service)}"
11
7
  end
@@ -34,8 +34,7 @@ namespace :nginx do
34
34
  task :setup do
35
35
  on roles :web do
36
36
  next if file_exists? nginx_sites_available_file
37
- template 'nginx_conf.erb', nginx_config_tmp_file
38
- sudo :mv, nginx_config_tmp_file, nginx_sites_available_file
37
+ sudo_upload! template('nginx_conf.erb'), nginx_sites_available_file
39
38
  sudo :ln, '-fs', nginx_sites_available_file, nginx_sites_enabled_file
40
39
  end
41
40
  end
@@ -46,8 +45,8 @@ namespace :nginx do
46
45
  on roles :web do
47
46
  next if file_exists?(nginx_ssl_cert_file) && file_exists?(nginx_ssl_cert_key_file)
48
47
  if fetch(:nginx_upload_local_cert)
49
- upload! fetch(:nginx_ssl_cert_local_path), nginx_ssl_cert_file
50
- upload! fetch(:nginx_ssl_cert_key_local_path), nginx_ssl_cert_key_file
48
+ sudo_upload! fetch(:nginx_ssl_cert_local_path), nginx_ssl_cert_file
49
+ sudo_upload! fetch(:nginx_ssl_cert_key_local_path), nginx_ssl_cert_key_file
51
50
  end
52
51
  sudo :chown, 'root:root', nginx_ssl_cert_file
53
52
  sudo :chown, 'root:root', nginx_ssl_cert_key_file
@@ -29,9 +29,8 @@ namespace :unicorn do
29
29
  task :setup_initializer do
30
30
  on roles :app do
31
31
  next if file_exists? unicorn_initd_file
32
- template 'unicorn_init.erb', unicorn_initd_tmp_file
33
- execute :chmod, '+x', unicorn_initd_tmp_file
34
- sudo :mv, unicorn_initd_tmp_file, unicorn_initd_file
32
+ sudo_upload! template('unicorn_init.erb'), unicorn_initd_file
33
+ execute :chmod, '+x', unicorn_initd_file
35
34
  sudo 'update-rc.d', '-f', fetch(:unicorn_service), 'defaults'
36
35
  end
37
36
  end
@@ -40,7 +39,7 @@ namespace :unicorn do
40
39
  task :setup_app_config do
41
40
  on roles :app do
42
41
  next if file_exists? fetch(:unicorn_config)
43
- template 'unicorn.rb.erb', fetch(:unicorn_config)
42
+ upload! template('unicorn.rb.erb'), fetch(:unicorn_config)
44
43
  end
45
44
  end
46
45
 
@@ -8,14 +8,13 @@ module Capistrano
8
8
  SSHKit::Command.new(:bundle, :exec, :unicorn, args).to_command
9
9
  end
10
10
 
11
- def template(template_name, target)
11
+ def template(template_name)
12
12
  config_file = "#{fetch(:templates_path)}/#{template_name}"
13
13
  # if no customized file, proceed with default
14
14
  unless File.exists?(config_file)
15
15
  config_file = File.join(File.dirname(__FILE__), "../../generators/capistrano/unicorn_nginx/templates/#{template_name}")
16
16
  end
17
- config_stream = StringIO.new(ERB.new(File.read(config_file)).result(binding))
18
- upload! config_stream, target
17
+ StringIO.new(ERB.new(File.read(config_file)).result(binding))
19
18
  end
20
19
 
21
20
  def file_exists?(path)
@@ -26,6 +25,14 @@ module Capistrano
26
25
  capture :id, '-un'
27
26
  end
28
27
 
28
+ def sudo_upload!(from, to)
29
+ filename = File.basename(to)
30
+ to_dir = File.dirname(to)
31
+ tmp_file = "#{fetch(:tmp_dir)}/#{filename}"
32
+ upload! from, tmp_file
33
+ sudo :mv, tmp_file, to_dir
34
+ end
35
+
29
36
  end
30
37
  end
31
38
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module UnicornNginx
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-unicorn-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Sutic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-29 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano