capistrano3-nginx_unicorn 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ca63dadb9199894b6ca18f4fdb6645fc4597fc7
4
+ data.tar.gz: dd6771567a3a1a849d5db4a407b3a14d15b3595e
5
+ SHA512:
6
+ metadata.gz: 60db9a9f0a332ac991d355e46a59d4a7006b42eaf2e6424208a2967b711ec9d5f59f9c11b9c936cc74f2f0d6aeaf63ffb2bc07a7b2fc2f7f38c8957b7898d0f1
7
+ data.tar.gz: 3cd45e8c988085bc3b5cd2d4b43b37d4bf90018b24e4dc0f2d87e226f3f92ba5293d62224537f9356b38e7a637a6c9ade454279fa791f40f2ac3112a2cde5287
data/README.md CHANGED
@@ -33,7 +33,7 @@ Or install it yourself as:
33
33
 
34
34
  Add this line to your `Capfile`
35
35
 
36
- require 'capistrano/nginx_unicorn'
36
+ require 'capistrano3/nginx_unicorn'
37
37
 
38
38
  Note, that following capistrano variables should be defined:
39
39
 
@@ -112,8 +112,8 @@ set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
112
112
  set :unicorn_config, "#{shared_path}/config/unicorn.rb"
113
113
 
114
114
  # path, where unicorn log file will be stored
115
- # default value: `"#{shared_path}/config/unicorn.rb"`
116
- set :unicorn_log, "#{shared_path}/config/unicorn.rb"
115
+ # default value: `"#{shared_path}/log/unicorn.log"`
116
+ set :unicorn_log, "#{shared_path}/log/unicorn.log"
117
117
 
118
118
  # user name to run unicorn
119
119
  # default value: `user` (user varibale defined in your `deploy.rb`)
@@ -158,21 +158,20 @@ your `deploy.rb` will look like this:
158
158
  ```ruby
159
159
  set :server_name, "example.com"
160
160
  set :unicorn_workers, 4
161
- require 'capistrano-nginx-unicorn'
162
161
  ```
163
162
 
164
163
  ### Template Customization
165
164
 
166
165
  If you want to change default templates, you can generate them using `rails generator`
167
166
 
168
- rails g capistrano:nginx_unicorn:config
167
+ rails g capistrano3:nginx_unicorn:config
169
168
 
170
169
  This will copy default templates to `config/deploy/templates` directory,
171
170
  so you can customize them as you like, and capistrano tasks will use this templates instead of default.
172
171
 
173
172
  You can also provide path, where to generate templates:
174
173
 
175
- rails g capistrano:nginx_unicorn:config config/templates
174
+ rails g capistrano3:nginx_unicorn:config config/templates
176
175
 
177
176
  # TODO:
178
177
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module NginxUnicorn
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -2,15 +2,16 @@ require 'capistrano'
2
2
 
3
3
  namespace :load do
4
4
  task :defaults do
5
- set :templates_path, "config/deploy/templates"
5
+ set :templates_path, "config/deploy/templates"
6
6
 
7
7
  set :nginx_server_name, -> { "www.example.com" }
8
- set :nginx_use_ssl, false
8
+ set :nginx_config_path, -> { "/etc/nginx" }
9
+ set :nginx_use_ssl, false
9
10
  set :nginx_ssl_certificate, -> { "#{fetch(:nginx_server_name)}.crt" }
10
11
  set :nginx_ssl_certificate_key, -> { "#{fetch(:nginx_server_name)}.key" }
11
12
  set :nginx_upload_local_certificate, -> { true }
12
- set :nginx_ssl_certificate_local_path, -> { "/etc/certificates/" }
13
- set :nginx_ssl_certificate_key_local_path, -> { "/etc/certificates/keys" }
13
+ set :nginx_ssl_certificate_local_path, -> { "../certificates/#{fetch(:nginx_ssl_certificate)}" }
14
+ set :nginx_ssl_certificate_key_local_path, -> { "../certificates/#{fetch(:nginx_ssl_certificate_key)}" }
14
15
 
15
16
  set :unicorn_pid, -> { "#{current_path}/tmp/pids/unicorn.pid" }
16
17
  set :unicorn_config, -> { "#{shared_path}/config/unicorn.rb" }
@@ -25,16 +26,20 @@ namespace :nginx do
25
26
  task :setup do
26
27
  on roles(:web) do
27
28
  template("nginx_conf.erb", "/tmp/#{fetch(:application)}.conf")
28
- execute "sudo mv /tmp/#{fetch(:application)}.conf /etc/nginx/sites-available/#{fetch(:application)}.conf"
29
- execute "sudo ln -fs /etc/nginx/sites-available/#{fetch(:application)}.conf /etc/nginx/sites-enabled/#{fetch(:application)}.conf"
29
+ execute "sudo mv /tmp/#{fetch(:application)}.conf #{fetch(:nginx_config_path)}/sites-available/#{fetch(:application)}.conf"
30
+ execute "sudo ln -fs #{fetch(:nginx_config_path)}/sites-available/#{fetch(:application)}.conf #{fetch(:nginx_config_path)}/sites-enabled/#{fetch(:application)}.conf"
30
31
 
31
32
  if fetch(:nginx_use_ssl)
32
- if nginx_upload_local_certificate
33
- put File.read(nginx_ssl_certificate_local_path), "/tmp/#{fetch(:nginx_ssl_certificate)}"
34
- put File.read(nginx_ssl_certificate_key_local_path), "/tmp/#{fetch(:nginx_ssl_certificate_key)}"
33
+ if fetch(:nginx_upload_local_certificate)
34
+ if File.exists?(fetch(:nginx_ssl_certificate_local_path))
35
+ upload! StringIO.new(File.read(fetch(:nginx_ssl_certificate_local_path))), "/tmp/#{fetch(:nginx_ssl_certificate)}"
36
+ execute "sudo mv /tmp/#{fetch(:nginx_ssl_certificate)} /etc/ssl/certs/#{fetch(:nginx_ssl_certificate)}"
37
+ end
38
+ if File.exists?(fetch(:nginx_ssl_certificate_key_local_path))
39
+ upload! StringIO.new(File.read(fetch(:nginx_ssl_certificate_key_local_path))), "/tmp/#{fetch(:nginx_ssl_certificate_key)}"
40
+ execute "sudo mv /tmp/#{fetch(:nginx_ssl_certificate_key)} /etc/ssl/private/#{fetch(:nginx_ssl_certificate_key)}"
41
+ end
35
42
 
36
- execute "sudo mv /tmp/#{fetch(:nginx_ssl_certificate)} /etc/ssl/certs/#{fetch(:nginx_ssl_certificate)}"
37
- execute "sudo mv /tmp/#{fetch(:nginx_ssl_certificate_key)} /etc/ssl/private/#{fetch(:nginx_ssl_certificate_key)}"
38
43
  end
39
44
 
40
45
  execute "sudo chown root:root /etc/ssl/certs/#{fetch(:nginx_ssl_certificate)}"
@@ -47,12 +52,13 @@ namespace :nginx do
47
52
  task :reload do
48
53
  on roles(:web) do
49
54
  execute "mkdir -p #{shared_path}/log"
50
- execute "sudo /etc/init.d/nginx reload"
55
+ execute "sudo /etc/init.d/nginx restart"
51
56
  end
52
57
  end
53
58
 
54
- after "deploy:check", "nginx:setup"
55
- after "deploy:finished", "nginx:reload"
59
+ # after "deploy:check", "nginx:setup"
60
+ # after "deploy:finished", "nginx:reload"
61
+ after "unicorn:setup", "nginx:setup"
56
62
 
57
63
  end
58
64
 
@@ -70,7 +76,7 @@ namespace :unicorn do
70
76
  end
71
77
  end
72
78
 
73
- after "deploy:check", "unicorn:setup"
79
+ # after "deploy:check", "unicorn:setup"
74
80
 
75
81
  end
76
82
 
@@ -88,14 +94,14 @@ end
88
94
 
89
95
  desc "Setup logs rotation for nginx and unicorn"
90
96
  task :logrotate do
91
- on roles([:web, :app]) do
97
+ on roles(:web, :app) do
92
98
  template("logrotate.erb", "/tmp/#{fetch(:application)}_logrotate")
93
99
  execute "sudo mv /tmp/#{fetch(:application)}_logrotate /etc/logrotate.d/#{fetch(:application)}"
94
100
  execute "sudo chown root:root /etc/logrotate.d/#{fetch(:application)}"
95
101
  end
96
102
  end
97
103
 
98
- after "deploy:check", "logrotate"
104
+ after "unicorn:setup", "logrotate"
99
105
 
100
106
  def template(template_name, target)
101
107
  config_file = "#{fetch(:templates_path)}/#{template_name}"
@@ -105,4 +111,3 @@ def template(template_name, target)
105
111
  end
106
112
  upload! StringIO.new(ERB.new(File.read(config_file)).result(binding)), target
107
113
  end
108
-
@@ -5,6 +5,7 @@ upstream unicorn_<%= fetch(:application) %> {
5
5
  <% if fetch(:nginx_use_ssl) %>
6
6
  server {
7
7
  listen 80;
8
+ server_name <%= fetch(:nginx_server_name) %>;
8
9
  rewrite ^(.*) https://$host$1 permanent;
9
10
  }
10
11
  <% end %>
@@ -19,7 +19,11 @@ PID=<%= fetch(:unicorn_pid) %>
19
19
  if [ "$RVM_TYPE" == "system" ]; then
20
20
  CMD="cd <%= current_path %>; rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'bundle exec unicorn -D -c <%= fetch(:unicorn_config) %> -E <%= fetch(:rails_env) %>'"
21
21
  else
22
- CMD="cd <%= current_path %>; source \"/home/<%= fetch(:user) %>/.rvm/environments/default\"; bundle exec unicorn -D -c <%= fetch(:unicorn_config) %> -E <%= fetch(:rails_env) %>"
22
+ <% if fetch(:rvm_ruby_version) %>
23
+ CMD="cd <%= current_path %>; source \"/home/<%= fetch(:user) %>/.rvm/environments/ruby-<%= fetch(:rvm_ruby_version) %>\"; bundle exec unicorn -D -c <%= fetch(:unicorn_config) %> -E <%= fetch(:rails_env) %>"
24
+ <% else %>
25
+ CMD="cd <%= current_path %>; source \"/home/<%= fetch(:user) %>/.rvm/environments/default\"; bundle exec unicorn -D -c <%= fetch(:unicorn_config) %> -E <%= fetch(:rails_env) %>"
26
+ <% end %>
23
27
  fi
24
28
 
25
29
  AS_USER=<%= fetch(:unicorn_user) %>
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano3-nginx_unicorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ivan Tkalin
@@ -10,38 +9,34 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-12-27 00:00:00.000000000 Z
12
+ date: 2016-09-20 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: capistrano
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 3.0.0
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 3.0.0
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  description: Capistrano v3 tasks for configuration and management nginx+unicorn combo
@@ -54,7 +49,7 @@ executables: []
54
49
  extensions: []
55
50
  extra_rdoc_files: []
56
51
  files:
57
- - .gitignore
52
+ - ".gitignore"
58
53
  - Gemfile
59
54
  - LICENSE.txt
60
55
  - README.md
@@ -72,27 +67,25 @@ files:
72
67
  - lib/generators/capistrano3/nginx_unicorn/templates/unicorn_init.erb
73
68
  homepage: https://github.com/jesson/capistrano3-nginx_unicorn
74
69
  licenses: []
70
+ metadata: {}
75
71
  post_install_message:
76
72
  rdoc_options: []
77
73
  require_paths:
78
74
  - lib
79
75
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
76
  requirements:
82
- - - ! '>='
77
+ - - ">="
83
78
  - !ruby/object:Gem::Version
84
79
  version: '0'
85
80
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
81
  requirements:
88
- - - ! '>='
82
+ - - ">="
89
83
  - !ruby/object:Gem::Version
90
84
  version: '0'
91
85
  requirements: []
92
86
  rubyforge_project:
93
- rubygems_version: 1.8.25
87
+ rubygems_version: 2.6.6
94
88
  signing_key:
95
- specification_version: 3
89
+ specification_version: 4
96
90
  summary: Create and manage nginx+unicorn configs from capistrano v3
97
91
  test_files: []
98
- has_rdoc: