capistrano-nginx-unicorn 0.0.3 → 0.0.4
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.
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Provides capistrano tasks to:
|
|
8
8
|
* create unicorn init script for application, so it will be automatically started when OS restarts
|
9
9
|
* start/stop unicorn (also can be done using `sudo service unicorn_<your_app> start/stop`)
|
10
10
|
* reload unicorn using `USR2` signal to load new application version with zero downtime
|
11
|
+
* creates logrotate record to rotate application logs
|
11
12
|
|
12
13
|
Provides several capistrano variables for easy customization.
|
13
14
|
Also, for full customization, all configs can be copied to the application using generators.
|
@@ -65,14 +66,19 @@ and for unicorn:
|
|
65
66
|
# then old workers will be automatically killed and new workers will start processing requests
|
66
67
|
cap unicorn:reload
|
67
68
|
|
69
|
+
and shared:
|
70
|
+
|
71
|
+
# create logrotate record to rotate application logs
|
72
|
+
cap logrotate
|
73
|
+
|
68
74
|
There is no need to execute any of these tasks manually.
|
69
75
|
They will be called automatically on different deploy stages:
|
70
76
|
|
71
|
-
* `nginx:setup`, `nginx:reload
|
77
|
+
* `nginx:setup`, `nginx:reload`, `unicorn:setup` and `logrotate` are hooked to `deploy:setup`
|
72
78
|
* `unicorn:restart` is hooked to `deploy:restart`
|
73
79
|
|
74
80
|
This means that if you run `cap deploy:setup`,
|
75
|
-
nginx and unicorn will be automatically configured
|
81
|
+
nginx and unicorn will be automatically configured.
|
76
82
|
And after each deploy, unicorn will be automatically reloaded.
|
77
83
|
|
78
84
|
However, if you changed variables or customized templates,
|
@@ -67,6 +67,15 @@ Capistrano::Configuration.instance.load do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
desc "Setup logs rotation for nginx and unicorn"
|
71
|
+
task :logrotate, roles: [:web, :app] do
|
72
|
+
template("logrotate.erb", "/tmp/#{application}_logrotate")
|
73
|
+
run "#{sudo} mv /tmp/#{application}_logrotate /etc/logrotate.d/#{application}"
|
74
|
+
run "#{sudo} chown root:root /etc/logrotate.d/#{application}"
|
75
|
+
end
|
76
|
+
|
77
|
+
after "deploy:setup", "logrotate"
|
78
|
+
|
70
79
|
def template(template_name, target)
|
71
80
|
config_file = "#{templates_path}/#{template_name}"
|
72
81
|
# if no customized file, proceed with default
|
@@ -12,6 +12,7 @@ module Capistrano
|
|
12
12
|
copy_file "nginx_conf.erb", "#{templates_path}/nginx_conf.erb"
|
13
13
|
copy_file "unicorn.rb.erb", "#{templates_path}/unicorn.rb.erb"
|
14
14
|
copy_file "unicorn_init.erb", "#{templates_path}/unicorn_init.erb"
|
15
|
+
copy_file "logrotate.erb", "#{templates_path}/logrotate.erb"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= shared_path %>/log/*.log {
|
2
|
+
daily
|
3
|
+
missingok
|
4
|
+
rotate 180
|
5
|
+
compress
|
6
|
+
dateext
|
7
|
+
delaycompress
|
8
|
+
|
9
|
+
lastaction
|
10
|
+
pid=<%= unicorn_pid %>
|
11
|
+
test -s $pid && kill -USR1 "$(cat $pid)"
|
12
|
+
endscript
|
13
|
+
|
14
|
+
prerotate
|
15
|
+
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
|
16
|
+
run-parts /etc/logrotate.d/httpd-prerotate; \
|
17
|
+
fi \
|
18
|
+
endscript
|
19
|
+
|
20
|
+
postrotate
|
21
|
+
[ ! -f /run/nginx.pid ] || kill -USR1 `cat /run/nginx.pid`
|
22
|
+
endscript
|
23
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-nginx-unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/capistrano/nginx_unicorn/version.rb
|
64
64
|
- lib/generators/capistrano/nginx_unicorn/USAGE
|
65
65
|
- lib/generators/capistrano/nginx_unicorn/config_generator.rb
|
66
|
+
- lib/generators/capistrano/nginx_unicorn/templates/logrotate.erb
|
66
67
|
- lib/generators/capistrano/nginx_unicorn/templates/nginx_conf.erb
|
67
68
|
- lib/generators/capistrano/nginx_unicorn/templates/unicorn.rb.erb
|
68
69
|
- lib/generators/capistrano/nginx_unicorn/templates/unicorn_init.erb
|
@@ -79,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
80
|
version: '0'
|
80
81
|
segments:
|
81
82
|
- 0
|
82
|
-
hash:
|
83
|
+
hash: 1031538304878768705
|
83
84
|
none: false
|
84
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
89
|
version: '0'
|
89
90
|
segments:
|
90
91
|
- 0
|
91
|
-
hash:
|
92
|
+
hash: 1031538304878768705
|
92
93
|
none: false
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|