capistrano3-puma 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -4
- data/lib/capistrano/puma.rb +1 -1
- data/lib/capistrano/puma/nginx.rb +1 -0
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/nginx.cap +10 -0
- data/lib/capistrano/tasks/puma.cap +11 -0
- data/lib/capistrano/templates/nginx_conf.erb +61 -0
- data/lib/generators/capistrano/nginx_puma/USAGE +9 -0
- data/lib/generators/capistrano/nginx_puma/config_generator.rb +21 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906e7e263c2cf0567f367308907420814fedf12d
|
4
|
+
data.tar.gz: cf6269ede1b1f672c1d38d5ff63ac008ffd30efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2bc17d7c278226a39664ee3da1e16c7f1e103c9c170b4074662f0263739f27ad66c67d751ec55d0321a23ebae677ddf062086ebb76ce44cbff5de7abf2b7c4
|
7
|
+
data.tar.gz: cf8c248c466623a27f5f41c614ead058998f5d87a511ee94416b9d223bbb5ee21b2532ea4a88ce9072f322278055a7853d4931ef8aab8c4d8137ea88026bcadb
|
data/README.md
CHANGED
@@ -20,12 +20,28 @@ And then execute:
|
|
20
20
|
|
21
21
|
require 'capistrano/puma'
|
22
22
|
require 'capistrano/puma/workers' #if you want to control the workers (in cluster mode)
|
23
|
-
require 'capistrano/puma/jungle'
|
24
|
-
require 'capistrano/puma/monit'
|
23
|
+
require 'capistrano/puma/jungle' #if you need the jungle tasks
|
24
|
+
require 'capistrano/puma/monit' #if you need the monit tasks
|
25
|
+
require 'capistrano/puma/nginx' #if you want to upload a nginx site template
|
25
26
|
```
|
26
27
|
|
28
|
+
then you can use ```cap -vT``` to list tasks
|
29
|
+
```
|
30
|
+
cap nginx:config # upload a nginx site config(eg. /etc/nginx/site-enabled/)
|
31
|
+
cap puma:config # upload puma config(eg. shared/puma.config)
|
32
|
+
```
|
33
|
+
you may want to customize these two templates localy before uploading
|
34
|
+
```
|
35
|
+
rails g capistrano:nginx_puma:config
|
36
|
+
```
|
37
|
+
|
38
|
+
if your nginx server configuration is not located in /etc/nginx, you may need to customize nginx_sites_available_path and nginx_sites_enabled_path
|
39
|
+
```
|
40
|
+
set :nginx_sites_available_path, "/etc/nginx/sites-available"
|
41
|
+
set :nginx_sites_enabled_path, "/etc/nginx/sites-enabled"
|
42
|
+
```
|
27
43
|
|
28
|
-
Configurable options, shown here with defaults: Please note the configuration options below are not required unless you are trying to override a default setting, for instance if you are deploying on a host on which you do not have sudo or root privileges and you need to restrict the path. These settings go in the deploy.rb file.
|
44
|
+
Configurable options, shown here with defaults: Please note the configuration options below are not required unless you are trying to override a default setting, for instance if you are deploying on a host on which you do not have sudo or root privileges and you need to restrict the path. These settings go in the deploy.rb file.
|
29
45
|
|
30
46
|
```ruby
|
31
47
|
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
|
@@ -67,6 +83,7 @@ Ensure that the following directories are shared (via ``linked_dirs``):
|
|
67
83
|
tmp/pids tmp/sockets log
|
68
84
|
|
69
85
|
## Changelog
|
86
|
+
- 0.7.0: added Nginx template generator @dfang
|
70
87
|
- 0.6.1: added :puma_default_hooks, you can turn off the automatic hooks by setting it false
|
71
88
|
- 0.6.0: Remove `daemonize true` from default puma.rb file. Explicitly pass `--daemon` flag when needed.
|
72
89
|
- 0.5.1: Added worker_timeout option
|
@@ -97,11 +114,12 @@ Ensure that the following directories are shared (via ``linked_dirs``):
|
|
97
114
|
|
98
115
|
## Contributors
|
99
116
|
|
100
|
-
- [Ruohan Chen]
|
117
|
+
- [Ruohan Chen](https://github.com/crhan)
|
101
118
|
- [molfar](https://github.com/molfar)
|
102
119
|
- [ayaya](https://github.com/ayamomiji)
|
103
120
|
- [Shane O'Grady](https://github.com/shaneog)
|
104
121
|
- [Jun Lin](https://github.com/linjunpop)
|
122
|
+
- [fang duan](https://github.com/dfang/capistrano-puma)
|
105
123
|
|
106
124
|
## Contributing
|
107
125
|
|
data/lib/capistrano/puma.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
load File.expand_path('../tasks/puma.cap', __FILE__)
|
1
|
+
load File.expand_path('../tasks/puma.cap', __FILE__)
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../../tasks/nginx.cap', __FILE__)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
desc "Setup nginx configuration"
|
3
|
+
task :config do
|
4
|
+
on roles(:puma_nginx) do
|
5
|
+
template_puma("nginx_conf", "/tmp/nginx_#{fetch(:nginx_config_name)}")
|
6
|
+
sudo :mv, "/tmp/nginx_#{fetch(:nginx_config_name)} #{fetch(:nginx_sites_available_path)}/#{fetch(:nginx_config_name)}"
|
7
|
+
sudo :ln, '-fs', "#{fetch(:nginx_sites_available_path)}/#{fetch(:nginx_config_name)} #{fetch(:nginx_sites_enabled_path)}/#{fetch(:nginx_config_name)}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -2,6 +2,7 @@ namespace :load do
|
|
2
2
|
task :defaults do
|
3
3
|
set :puma_default_hooks, -> { true }
|
4
4
|
set :puma_role, :app
|
5
|
+
set :puma_nginx_role, :web
|
5
6
|
set :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
|
6
7
|
# Configure "min" to be the minimum number of threads to use to answer
|
7
8
|
# requests and "max" the maximum.
|
@@ -20,6 +21,13 @@ namespace :load do
|
|
20
21
|
# Rbenv and RVM integration
|
21
22
|
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w{ puma pumactl })
|
22
23
|
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w{ puma pumactl })
|
24
|
+
|
25
|
+
# Nginx and puma configuration
|
26
|
+
set :nginx_config_name, -> { "#{fetch(:application)}_#{fetch(:stage)}" }
|
27
|
+
set :nginx_sites_available_path, -> { '/etc/nginx/sites-available' }
|
28
|
+
set :nginx_sites_enabled_path, -> { '/etc/nginx/sites-enabled' }
|
29
|
+
set :nginx_server_name, -> { "localhost #{fetch(:application)}.local" }
|
30
|
+
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
@@ -134,6 +142,9 @@ namespace :puma do
|
|
134
142
|
"lib/capistrano/templates/#{from}.rb.erb",
|
135
143
|
"lib/capistrano/templates/#{from}.rb",
|
136
144
|
"lib/capistrano/templates/#{from}.erb",
|
145
|
+
"config/deploy/templates/#{from}.rb.erb",
|
146
|
+
"config/deploy/templates/#{from}.rb",
|
147
|
+
"config/deploy/templates/#{from}.erb",
|
137
148
|
File.expand_path("../../templates/#{from}.rb.erb", __FILE__),
|
138
149
|
File.expand_path("../../templates/#{from}.erb", __FILE__)
|
139
150
|
].each do |path|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
upstream puma_<%= fetch(:nginx_config_name) %> {
|
2
|
+
server <%= fetch(:puma_bind) %> fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80;
|
7
|
+
|
8
|
+
client_max_body_size 4G;
|
9
|
+
keepalive_timeout 10;
|
10
|
+
|
11
|
+
error_page 500 502 504 /500.html;
|
12
|
+
error_page 503 @503;
|
13
|
+
|
14
|
+
server_name <%= fetch(:nginx_server_name) %>;
|
15
|
+
root <%= current_path %>/public;
|
16
|
+
try_files $uri/index.html $uri @puma_<%= fetch(:nginx_config_name) %>;
|
17
|
+
|
18
|
+
location @puma_<%= fetch(:nginx_config_name) %> {
|
19
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
20
|
+
proxy_set_header Host $http_host;
|
21
|
+
proxy_redirect off;
|
22
|
+
proxy_pass http://puma_<%= fetch(:nginx_config_name) %>;
|
23
|
+
# limit_req zone=one;
|
24
|
+
access_log <%= shared_path %>/log/nginx.access.log;
|
25
|
+
error_log <%= shared_path %>/log/nginx.error.log;
|
26
|
+
}
|
27
|
+
|
28
|
+
location ^~ /assets/ {
|
29
|
+
gzip_static on;
|
30
|
+
expires max;
|
31
|
+
add_header Cache-Control public;
|
32
|
+
}
|
33
|
+
|
34
|
+
location = /50x.html {
|
35
|
+
root html;
|
36
|
+
}
|
37
|
+
|
38
|
+
location = /404.html {
|
39
|
+
root html;
|
40
|
+
}
|
41
|
+
|
42
|
+
location @503 {
|
43
|
+
error_page 405 = /system/maintenance.html;
|
44
|
+
if (-f $document_root/system/maintenance.html) {
|
45
|
+
rewrite ^(.*)$ /system/maintenance.html break;
|
46
|
+
}
|
47
|
+
rewrite ^(.*)$ /503.html break;
|
48
|
+
}
|
49
|
+
|
50
|
+
if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$ ){
|
51
|
+
return 405;
|
52
|
+
}
|
53
|
+
|
54
|
+
if (-f $document_root/system/maintenance.html) {
|
55
|
+
return 503;
|
56
|
+
}
|
57
|
+
|
58
|
+
location ~ \.(php|html)$ {
|
59
|
+
return 405;
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
To create local nginx and puma configuration files call
|
2
|
+
|
3
|
+
rails generate capistrano:nginx_puma:config [path]
|
4
|
+
|
5
|
+
The default path is "config/deploy/templates". You can override it like so:
|
6
|
+
|
7
|
+
rails generate capistrano:nginx_puma:config "config/templates"
|
8
|
+
|
9
|
+
If you override templates path, don't forget to set "templates_path" variable in your deploy.rb
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module NginxPuma
|
3
|
+
module Generators
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
desc "Create local nginx and puma configuration files for customization"
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
argument :templates_path, :type => :string,
|
8
|
+
:default => "config/deploy/templates",
|
9
|
+
:banner => "path to templates"
|
10
|
+
|
11
|
+
def copy_template
|
12
|
+
copy_file "../../../../capistrano/templates/puma.rb.erb", "#{templates_path}/puma.rb.erb"
|
13
|
+
copy_file "../../../../capistrano/templates/nginx_conf.erb", "#{templates_path}/nginx_conf.erb"
|
14
|
+
# copy_file "puma.rb.erb", "#{templates_path}/puma.rb.erb"
|
15
|
+
# copy_file "puma_init.erb", "#{templates_path}/puma_init.erb"
|
16
|
+
# copy_file "logrotate.erb", "#{templates_path}/logrotate.erb"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano3-puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -55,17 +55,22 @@ files:
|
|
55
55
|
- lib/capistrano/puma.rb
|
56
56
|
- lib/capistrano/puma/jungle.rb
|
57
57
|
- lib/capistrano/puma/monit.rb
|
58
|
+
- lib/capistrano/puma/nginx.rb
|
58
59
|
- lib/capistrano/puma/version.rb
|
59
60
|
- lib/capistrano/puma/workers.rb
|
60
61
|
- lib/capistrano/tasks/jungle.cap
|
61
62
|
- lib/capistrano/tasks/monit.cap
|
63
|
+
- lib/capistrano/tasks/nginx.cap
|
62
64
|
- lib/capistrano/tasks/puma.cap
|
63
65
|
- lib/capistrano/tasks/workers.cap
|
66
|
+
- lib/capistrano/templates/nginx_conf.erb
|
64
67
|
- lib/capistrano/templates/puma-deb.erb
|
65
68
|
- lib/capistrano/templates/puma-rpm.erb
|
66
69
|
- lib/capistrano/templates/puma.rb.erb
|
67
70
|
- lib/capistrano/templates/puma_monit.conf.erb
|
68
71
|
- lib/capistrano/templates/run-puma.erb
|
72
|
+
- lib/generators/capistrano/nginx_puma/USAGE
|
73
|
+
- lib/generators/capistrano/nginx_puma/config_generator.rb
|
69
74
|
homepage: https://github.com/seuros/capistrano-puma
|
70
75
|
licenses:
|
71
76
|
- MIT
|
@@ -88,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
93
|
version: '0'
|
89
94
|
requirements: []
|
90
95
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.4.1
|
92
97
|
signing_key:
|
93
98
|
specification_version: 4
|
94
99
|
summary: Puma integration for Capistrano
|