capistrano-unicorn-nginx 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/capistrano/dsl/unicorn_paths.rb +9 -2
- data/lib/capistrano/tasks/nginx.rake +1 -0
- data/lib/capistrano/tasks/unicorn.rake +16 -0
- data/lib/capistrano/unicorn_nginx/version.rb +1 -1
- data/lib/generators/capistrano/unicorn_nginx/templates/nginx_conf.erb +2 -2
- data/lib/generators/capistrano/unicorn_nginx/templates/unicorn-logrotate.rb.erb +25 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fa7684b9edfa61257f2b2bb53b1459efe853b8
|
4
|
+
data.tar.gz: 28a21acc6aa76bb167246ddef2e7dbecc11bb38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ec2f6f9fd7cae579ebe7c87f078842f56d380ef3f899f336fe789b432a411eaeec2520f0ff41ba000115c624df3c9c092bd6c74af62d7dfca981f2285eff3b
|
7
|
+
data.tar.gz: a9e7f049219a0c771ddf04639841317f3ed188f38f9243302a9134d2b58e23f54df26ebfa4c4d6b59918a313e84c51ff70bd7ac24dff5060a8ef53884de99b30
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
### master
|
4
4
|
|
5
|
+
### v3.3.1, 2015-02-16
|
6
|
+
- made nginx fail_timeout configurable (@rhomeister)
|
7
|
+
- added logrotate configuration for nginx logs (@rhomeister)
|
8
|
+
|
5
9
|
### v3.3.0, 2015-02-09
|
6
10
|
- added client SSL authentication (@rhomeister)
|
7
11
|
- make unicorn timeout configurable (@vicentllongo)
|
@@ -14,14 +14,21 @@ module Capistrano
|
|
14
14
|
shared_path.join('tmp/pids/unicorn.pid')
|
15
15
|
end
|
16
16
|
|
17
|
+
def unicorn_log_dir
|
18
|
+
shared_path.join('log')
|
19
|
+
end
|
20
|
+
|
17
21
|
def unicorn_log_file
|
18
|
-
|
22
|
+
log_dir.join('unicorn.stdout.log')
|
19
23
|
end
|
20
24
|
|
21
25
|
def unicorn_error_log_file
|
22
|
-
|
26
|
+
log_dir.join('unicorn.stderr.log')
|
23
27
|
end
|
24
28
|
|
29
|
+
def unicorn_default_logrotate_config_file
|
30
|
+
"/etc/logrotate.d/#{fetch(:unicorn_service)}"
|
31
|
+
end
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -21,6 +21,7 @@ namespace :load do
|
|
21
21
|
set :nginx_upload_local_cert, true
|
22
22
|
set :nginx_ssl_cert_local_path, -> { ask(:nginx_ssl_cert_local_path, 'Local path to ssl certificate: ') }
|
23
23
|
set :nginx_ssl_cert_key_local_path, -> { ask(:nginx_ssl_cert_key_local_path, 'Local path to ssl certificate key: ') }
|
24
|
+
set :nginx_fail_timeout, 0 # see http://nginx.org/en/docs/http/ngx_http_upstream_module.html#fail_timeout
|
24
25
|
|
25
26
|
set :linked_dirs, fetch(:linked_dirs, []).push('log')
|
26
27
|
end
|
@@ -10,6 +10,7 @@ namespace :load do
|
|
10
10
|
set :templates_path, 'config/deploy/templates'
|
11
11
|
set :unicorn_pid, -> { unicorn_default_pid_file }
|
12
12
|
set :unicorn_config, -> { unicorn_default_config_file }
|
13
|
+
set :unicorn_logrotate_config, -> { unicorn_default_logrotate_config_file }
|
13
14
|
set :unicorn_workers, 2
|
14
15
|
set :unicorn_worker_timeout, 30
|
15
16
|
set :unicorn_tcp_listen_port, 8080
|
@@ -17,6 +18,8 @@ namespace :load do
|
|
17
18
|
set :unicorn_app_env, -> { fetch(:rails_env) || fetch(:stage) }
|
18
19
|
# set :unicorn_user # default set in `unicorn:defaults` task
|
19
20
|
|
21
|
+
set :unicorn_logrotate_enabled, false # by default, don't use logrotate to rotate unicorn logs
|
22
|
+
|
20
23
|
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids')
|
21
24
|
end
|
22
25
|
end
|
@@ -46,6 +49,15 @@ namespace :unicorn do
|
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
52
|
+
desc 'Setup logrotate configuration'
|
53
|
+
task :setup_logrotate do
|
54
|
+
on roles :app do
|
55
|
+
sudo :mkdir, '-pv', File.dirname(fetch(:unicorn_logrotate_config))
|
56
|
+
sudo_upload! template('unicorn-logrotate.rb.erb'), fetch(:unicorn_logrotate_config)
|
57
|
+
sudo 'chown', 'root:root', fetch(:unicorn_logrotate_config)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
49
61
|
%w[start stop restart].each do |command|
|
50
62
|
desc "#{command} unicorn"
|
51
63
|
task command do
|
@@ -56,6 +68,7 @@ namespace :unicorn do
|
|
56
68
|
end
|
57
69
|
|
58
70
|
before :setup_initializer, :defaults
|
71
|
+
before :setup_logrotate, :defaults
|
59
72
|
|
60
73
|
end
|
61
74
|
|
@@ -67,4 +80,7 @@ desc 'Server setup tasks'
|
|
67
80
|
task :setup do
|
68
81
|
invoke 'unicorn:setup_initializer'
|
69
82
|
invoke 'unicorn:setup_app_config'
|
83
|
+
if fetch(:unicorn_logrotate_enabled)
|
84
|
+
invoke 'unicorn:setup_logrotate'
|
85
|
+
end
|
70
86
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
upstream unicorn_<%= fetch(:nginx_config_name) %> {
|
2
2
|
<% if fetch(:unicorn_use_tcp) %>
|
3
3
|
<% roles(:app).each do |role| %>
|
4
|
-
server <%= role.hostname %>:<%= fetch(:unicorn_tcp_listen_port)%> fail_timeout
|
4
|
+
server <%= role.hostname %>:<%= fetch(:unicorn_tcp_listen_port)%> fail_timeout=<%= fetch(:nginx_fail_timeout) %>;
|
5
5
|
<% end %>
|
6
6
|
<% else %>
|
7
|
-
server unix:/tmp/unicorn.<%= fetch(:nginx_config_name) %>.sock fail_timeout
|
7
|
+
server unix:/tmp/unicorn.<%= fetch(:nginx_config_name) %>.sock fail_timeout=<%= fetch(:nginx_fail_timeout) %>;
|
8
8
|
<% end %>
|
9
9
|
}
|
10
10
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# logrotate.erb.conf
|
2
|
+
# Logrotate config for <%= fetch(:application) %> <%= fetch(:stage) %>
|
3
|
+
# Generated at <%= Time.now.strftime("%d.%m.%Y, %H:%M") %>
|
4
|
+
|
5
|
+
<%= unicorn_log_dir %>/*.log {
|
6
|
+
daily
|
7
|
+
missingok
|
8
|
+
rotate 180
|
9
|
+
compress
|
10
|
+
dateext
|
11
|
+
su <%= fetch(:unicorn_user) %> <%= fetch(:unicorn_user) %>
|
12
|
+
|
13
|
+
# this is important if using "compress" since we need to call
|
14
|
+
# the "lastaction" script below before compressing:
|
15
|
+
delaycompress
|
16
|
+
|
17
|
+
# note the lack of the evil "copytruncate" option in this
|
18
|
+
# config. Unicorn supports the USR1 signal and we send it
|
19
|
+
# as our "lastaction" action:
|
20
|
+
# USR1 - reopen all logs owned by the master and all workers
|
21
|
+
lastaction
|
22
|
+
pid=<%= fetch(:unicorn_pid) %>
|
23
|
+
test -s $pid && kill -USR1 "$(cat $pid)"
|
24
|
+
endscript
|
25
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-unicorn-nginx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Stranders
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-02-
|
12
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/generators/capistrano/unicorn_nginx/config_generator.rb
|
86
86
|
- lib/generators/capistrano/unicorn_nginx/templates/_default_server_directive.erb
|
87
87
|
- lib/generators/capistrano/unicorn_nginx/templates/nginx_conf.erb
|
88
|
+
- lib/generators/capistrano/unicorn_nginx/templates/unicorn-logrotate.rb.erb
|
88
89
|
- lib/generators/capistrano/unicorn_nginx/templates/unicorn.rb.erb
|
89
90
|
- lib/generators/capistrano/unicorn_nginx/templates/unicorn_init.erb
|
90
91
|
homepage: https://github.com/bruno-/capistrano-unicorn-nginx
|