capistrano3-puma 0.0.7 → 0.1.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 +25 -9
- data/lib/capistrano/puma/monit.rb +2 -0
- data/lib/capistrano/puma/nginx.rb +2 -0
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/jungle.cap +5 -6
- data/lib/capistrano/tasks/monit.cap +32 -0
- data/lib/capistrano/tasks/nginx.cap +17 -0
- data/lib/capistrano/tasks/puma.cap +51 -15
- data/lib/capistrano/templates/monit.conf.erb +14 -0
- data/lib/capistrano/templates/nginx.conf.erb +216 -0
- data/lib/capistrano/templates/puma-deb.erb +21 -20
- data/lib/capistrano/templates/puma.rb.erb +1 -1
- data/lib/capistrano/templates/run-puma.erb +8 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d71dc0edb29b8856ac842c1fad416d01c7f6956
|
4
|
+
data.tar.gz: d31c166a6ab2e6bab255b6753a28e3b8b2b25fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3da657d08ba95d780293a1bf19997a423dd895f251eec9d58f673d8bfb9af36a696b722f4648637cecc2303f5266d96cf4bc501c66783739a16b24917a751c7e
|
7
|
+
data.tar.gz: d24f24ffcc1b129c440ede8df04acd30223ff30b534358ac6b96f3e5f0db024b4be86576031ba8163273ab410aa8bf3b1beb2ce48cb8e69cda4fbbcbe0bf58b2
|
data/README.md
CHANGED
@@ -6,41 +6,57 @@ Add this line to your application's Gemfile:
|
|
6
6
|
|
7
7
|
gem 'capistrano-puma', github: "seuros/capistrano-puma"
|
8
8
|
|
9
|
+
or:
|
10
|
+
|
11
|
+
gem 'capistrano3-puma'
|
12
|
+
|
9
13
|
And then execute:
|
10
14
|
|
11
15
|
$ bundle
|
12
16
|
|
13
17
|
## Usage
|
14
|
-
|
18
|
+
```ruby
|
15
19
|
# Capfile
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
require 'capistrano/puma'
|
22
|
+
require 'capistrano/puma/jungle' #if you need the jungle tasks
|
23
|
+
```
|
20
24
|
|
21
25
|
|
22
26
|
Configurable options, shown here with defaults:
|
23
|
-
|
27
|
+
```ruby
|
24
28
|
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
|
25
29
|
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
|
26
30
|
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
|
27
|
-
set :puma_conf, "#{shared_path}/
|
31
|
+
set :puma_conf, "#{shared_path}/puma.rb"
|
28
32
|
set :puma_access_log, "#{shared_path}/log/puma_error.log"
|
29
33
|
set :puma_error_log, "#{shared_path}/log/puma_access.log"
|
30
34
|
set :puma_role, :app
|
31
35
|
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
|
32
36
|
set :puma_threads, [0, 16]
|
33
37
|
set :puma_workers, 0
|
38
|
+
```
|
39
|
+
For Jungle tasks (beta), these options exist:
|
40
|
+
```ruby
|
41
|
+
set :puma_jungle_conf, '/etc/puma.conf'
|
42
|
+
set :puma_run_path, '/usr/local/bin/run-puma'
|
43
|
+
```
|
44
|
+
Ensure that the following directories are shared (via ``linked_dirs``):
|
34
45
|
|
35
|
-
|
36
|
-
set :puma_cmd, "#{fetch(:bundle_cmd, 'bundle')} exec puma"
|
37
|
-
set :pumactl_cmd, "#{fetch(:bundle_cmd, 'bundle')} exec pumactl"
|
46
|
+
tmp/pids tmp/sockets log
|
38
47
|
|
48
|
+
## Changelog
|
39
49
|
|
50
|
+
- 0.1.0: Phased restart will be used if puma is in cluster mode
|
51
|
+
- 0.0.9: puma.rb location changed to shared_path root. puma:check moved to after deploy:check
|
52
|
+
- 0.0.8: puma.rb is automatically generated if not present. Fixed RVM issue.
|
53
|
+
- 0.0.7: Gem pushed to rubygems as capistrano3-puma. Support of Redhat based OS for Jungle init script.
|
40
54
|
|
41
55
|
## Contributors
|
42
56
|
|
43
57
|
[molfar](https://github.com/molfar)
|
58
|
+
[ayaya](https://github.com/ayamomiji)
|
59
|
+
[Shane O'Grady](https://github.com/shaneog)
|
44
60
|
|
45
61
|
|
46
62
|
## Contributing
|
@@ -15,16 +15,15 @@ namespace :puma do
|
|
15
15
|
template_puma 'run-puma.erb', "#{fetch(:tmp_dir)}/run-puma"
|
16
16
|
execute "chmod +x #{fetch(:tmp_dir)}/run-puma"
|
17
17
|
sudo "mv #{fetch(:tmp_dir)}/run-puma #{fetch(:puma_run_path)}"
|
18
|
-
if test
|
18
|
+
if test '[ -f /etc/lsb-release ]'
|
19
19
|
#Debian flavor OS
|
20
20
|
debian_install
|
21
|
-
elsif test
|
21
|
+
elsif test '[ -f /etc/redhat-release ]'
|
22
22
|
#RHEL flavor OS
|
23
23
|
rhel_install
|
24
24
|
else
|
25
25
|
#Some other OS
|
26
|
-
|
27
|
-
puts 'This task is not supported for your OS'
|
26
|
+
error 'This task is not supported for your OS'
|
28
27
|
end
|
29
28
|
sudo "touch #{fetch(:puma_jungle_conf)}"
|
30
29
|
end
|
@@ -35,7 +34,7 @@ namespace :puma do
|
|
35
34
|
template_puma 'puma-deb.erb', "#{fetch(:tmp_dir)}/puma"
|
36
35
|
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
37
36
|
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
38
|
-
sudo
|
37
|
+
sudo 'update-rc.d -f puma defaults'
|
39
38
|
|
40
39
|
end
|
41
40
|
|
@@ -43,7 +42,7 @@ namespace :puma do
|
|
43
42
|
template_puma 'puma-rpm.erb', "#{fetch(:tmp_dir)}/puma"
|
44
43
|
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
45
44
|
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
46
|
-
sudo
|
45
|
+
sudo 'chkconfig --add puma'
|
47
46
|
end
|
48
47
|
|
49
48
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
# set :puma_monit, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
namespace :puma do
|
9
|
+
namespace :monit do
|
10
|
+
desc 'Config Puma monit-service'
|
11
|
+
task :config do
|
12
|
+
on roles(fetch(:puma_role)) do
|
13
|
+
template_puma 'monit.conf.erb', "#{fetch(:tmp_dir)}/monit.test"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Enable Puma monit-service'
|
18
|
+
task :enable do
|
19
|
+
on roles(fetch(:puma_role)) do
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Disable Puma monit-service'
|
25
|
+
task :disable do
|
26
|
+
on roles(fetch(:puma_role)) do
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
set :nginx_access_log, -> { File.join(shared_path, 'log', 'nginx_error.log') }
|
4
|
+
set :nginx_error_log, -> { File.join(shared_path, 'log', 'nginx_access.log') }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :puma do
|
9
|
+
namespace :nginx do
|
10
|
+
desc 'Config Puma nginx-server'
|
11
|
+
task :config do
|
12
|
+
on roles(fetch(:puma_role)) do
|
13
|
+
template_puma 'nginx.conf.erb', "#{fetch(:tmp_dir)}/nginx.test"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
namespace :deploy do
|
2
|
-
after :finished, 'puma:
|
2
|
+
after :finished, 'puma:smart_restart'
|
3
3
|
end
|
4
4
|
|
5
5
|
namespace :load do
|
@@ -13,7 +13,7 @@ namespace :load do
|
|
13
13
|
set :puma_state, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
|
14
14
|
set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
15
15
|
set :puma_bind, -> { File.join('unix://', shared_path, 'tmp', 'sockets', 'puma.sock') }
|
16
|
-
set :puma_conf, -> { File.join(shared_path, '
|
16
|
+
set :puma_conf, -> { File.join(shared_path, 'puma.rb') }
|
17
17
|
set :puma_access_log, -> { File.join(shared_path, 'log', 'puma_error.log') }
|
18
18
|
set :puma_error_log, -> { File.join(shared_path, 'log', 'puma_access.log') }
|
19
19
|
|
@@ -36,32 +36,68 @@ namespace :puma do
|
|
36
36
|
task :start do
|
37
37
|
on roles (fetch(:puma_role)) do
|
38
38
|
within current_path do
|
39
|
-
|
40
|
-
if fetch(:puma_cmd)
|
41
|
-
execute "#{fetch(:puma_cmd)} -C #{fetch(:puma_conf)}"
|
42
|
-
else
|
43
|
-
execute :puma, "-C #{fetch(:puma_conf)}"
|
44
|
-
end
|
39
|
+
execute :bundle, 'exec', :puma, "-C #{fetch(:puma_conf)}"
|
45
40
|
end
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
49
|
-
%w[halt stop
|
44
|
+
%w[halt stop phased-restart status].each do |command|
|
50
45
|
desc "#{command} puma"
|
51
46
|
task command do
|
52
47
|
on roles (fetch(:puma_role)) do
|
53
48
|
within current_path do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
execute :bundle, 'exec', :pumactl, "-S #{fetch(:puma_state)} #{command}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'Restart puma'
|
56
|
+
task :restart do
|
57
|
+
on roles (fetch(:puma_role)) do
|
58
|
+
within current_path do
|
59
|
+
if test "[ -f #{fetch(:puma_state)} ]"
|
60
|
+
execute :bundle, 'exec', :pumactl, "-S #{fetch(:puma_state)} restart"
|
61
|
+
else
|
62
|
+
# Puma is not running or state file is not present : Run it
|
63
|
+
# TODO check for pid
|
64
|
+
execute :bundle, 'exec', :puma, "-C #{fetch(:puma_conf)}"
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
70
|
+
|
71
|
+
task :check do
|
72
|
+
on roles (fetch(:puma_role)) do
|
73
|
+
#Create puma.rb for new deployments
|
74
|
+
unless test "[ -f #{fetch(:puma_conf)} ]"
|
75
|
+
warn 'puma.rb NOT FOUND!'
|
76
|
+
#TODO DRY
|
77
|
+
template_puma 'puma.rb.erb', fetch(:puma_conf)
|
78
|
+
info 'puma.rb generated'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
after 'deploy:check', 'puma:check'
|
83
|
+
|
84
|
+
task :smart_restart do
|
85
|
+
if puma_workers.to_i > 1
|
86
|
+
invoke 'puma:phased-restart'
|
87
|
+
else
|
88
|
+
invoke 'puma:restart'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def processors_count
|
93
|
+
#TODO , will be used to warn if # of workers is > of available cores
|
94
|
+
capture 'grep -c processor /proc/cpuinfo'
|
95
|
+
end
|
96
|
+
|
97
|
+
def puma_workers
|
98
|
+
fetch(:puma_workers) || 0
|
99
|
+
end
|
100
|
+
|
65
101
|
def template_puma(from, to)
|
66
102
|
erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
|
67
103
|
upload! StringIO.new(ERB.new(erb).result(binding)), to
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Monit configuration for Puma
|
2
|
+
# Service name: <%= fetch(:puma_monit_service_name) %>
|
3
|
+
#
|
4
|
+
check process <%= fetch(:puma_monit_service_name) %>
|
5
|
+
with pidfile <%= fetch(:puma_pid) %>
|
6
|
+
start program = "/bin/su - <%= fetch(:user) %> -c '/usr/bin/env PATH=/home/user/.rbenv/shims:/home/user/.rbenv/bin:$PATH /home/user/puma.sh start'"
|
7
|
+
stop program = "/bin/su - <%= fetch(:user) %> -c '/usr/bin/env PATH=/home/user/.rbenv/shims:/home/user/.rbenv/bin:$PATH /home/user/puma.sh stop'"
|
8
|
+
if mem is greater than <%= fetch(:puma_monit_memory_alert_threshold) %> then alert
|
9
|
+
if mem is greater than <%= fetch(:puma_monit_memory_restart_threshold) %> then restart
|
10
|
+
if cpu is greater than <%= fetch(:puma_monit_cpu_alert_threshold) %> then alert
|
11
|
+
if cpu is greater than <%= fetch(:puma_monit_cpu_restart_threshold) %> then restart
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,216 @@
|
|
1
|
+
# Nginx configuration
|
2
|
+
# <%= "#{fetch(:application)} running as #{fetch(:user)} in environment production" %>
|
3
|
+
#
|
4
|
+
#
|
5
|
+
|
6
|
+
upstream <%= fetch(:application) %> {
|
7
|
+
server <%= fetch(:puma_bind) %> fail_timeout=0;
|
8
|
+
}
|
9
|
+
|
10
|
+
<% if fetch(:nginx_uses_http) %>
|
11
|
+
#
|
12
|
+
# HTTP server configuration
|
13
|
+
#
|
14
|
+
server {
|
15
|
+
listen <%= fetch(:nginx_port) %>;
|
16
|
+
client_max_body_size <%= fetch(:nginx_client_max_body_size) %>;
|
17
|
+
server_name <%= fetch(:server_names, '_') %>;
|
18
|
+
|
19
|
+
# ~2 seconds is often enough for most folks to parse HTML/CSS and
|
20
|
+
# retrieve needed images/icons/frames, connections are cheap in
|
21
|
+
# nginx so increasing this is generally safe...
|
22
|
+
# 8 seconds might be needed for some mobile devs
|
23
|
+
keepalive_timeout 8;
|
24
|
+
|
25
|
+
# path for static files
|
26
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
27
|
+
access_log <%= fetch(:nginx_access_log) %>;
|
28
|
+
error_log <%= fetch(:nginx_error_log) %> info;
|
29
|
+
|
30
|
+
# this rewrites all the requests to the maintenance.html
|
31
|
+
# page if it exists in the doc root. This is for capistrano's
|
32
|
+
# disable web task
|
33
|
+
if (-f $document_root/system/maintenance.html) {
|
34
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
|
38
|
+
location / {
|
39
|
+
<% if fetch(:nginx_use_simple_auth) %>
|
40
|
+
auth_basic "<%= fetch(:nginx_simple_auth_message) %>";
|
41
|
+
auth_basic_user_file <%= fetch(:nginx_remote_htpasswd) %>;
|
42
|
+
<% end %>
|
43
|
+
|
44
|
+
# needed to forward user's IP address to rails
|
45
|
+
proxy_set_header X-Real-IP $remote_addr;
|
46
|
+
|
47
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
48
|
+
proxy_set_header Host $http_host;
|
49
|
+
|
50
|
+
# if the request is for a static resource, nginx should serve it directly
|
51
|
+
# and add a far future expires header to it, making the browser
|
52
|
+
# cache the resource and navigate faster over the website.
|
53
|
+
location ~ ^/(assets)/.+-([0-9a-zA-Z])+\. {
|
54
|
+
gzip_static on;
|
55
|
+
expires max;
|
56
|
+
add_header Cache-Control public;
|
57
|
+
}
|
58
|
+
|
59
|
+
# Serve images outside the asset path
|
60
|
+
# Now this supposedly should work as it gets the filenames with querystrings that Rails provides.
|
61
|
+
# BUT there's a chance it could break the ajax calls.
|
62
|
+
location ~* \.(ico|css|gif|jpe?g|png)(\?[0-9]+)?$ {
|
63
|
+
expires max;
|
64
|
+
}
|
65
|
+
|
66
|
+
# Serve javascript outside the asset path
|
67
|
+
location ~ ^/javascripts/.*\.js(\?[0-9]+)?$ {
|
68
|
+
expires max;
|
69
|
+
}
|
70
|
+
|
71
|
+
# If the file exists as a static file serve it directly without
|
72
|
+
# running all the other rewrite tests on it
|
73
|
+
if (-f $request_filename) {
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
|
77
|
+
# check for index.html for directory index
|
78
|
+
# if its there on the filesystem then rewite
|
79
|
+
# the url to add /index.html to the end of it
|
80
|
+
# and then break to send it to the next config rules.
|
81
|
+
if (-f $request_filename/index.html) {
|
82
|
+
rewrite (.*) $1/index.html break;
|
83
|
+
}
|
84
|
+
|
85
|
+
# this is the meat of the rails page caching config
|
86
|
+
# it adds .html to the end of the url and then checks
|
87
|
+
# the filesystem for that file. If it exists, then we
|
88
|
+
# rewite the url to have explicit .html on the end
|
89
|
+
# and then send it on its way to the next config rule.
|
90
|
+
# if there is no file on the fs then it sets all the
|
91
|
+
# necessary headers and proxies to our upstream mongrels
|
92
|
+
if (-f $request_filename.html) {
|
93
|
+
rewrite (.*) $1.html break;
|
94
|
+
}
|
95
|
+
|
96
|
+
if (!-f $request_filename) {
|
97
|
+
proxy_pass http://<%= upstream_name %>;
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
# Rails error pages
|
103
|
+
error_page 500 502 503 504 /500.html;
|
104
|
+
location = /500.html {
|
105
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
<% end %>
|
109
|
+
|
110
|
+
<% if fetch(:nginx_uses_ssl) %>
|
111
|
+
#
|
112
|
+
# HTTPs server configuration
|
113
|
+
#
|
114
|
+
upstream <%= upstream_name_ssl %> {
|
115
|
+
server unix:<%= File.join("#{fetch(:shared_path)}","sockets", "puma.sock") %> fail_timeout=0;
|
116
|
+
}
|
117
|
+
|
118
|
+
# This server is setup for ssl. Uncomment if
|
119
|
+
# you are using ssl as well as port 80.
|
120
|
+
server {
|
121
|
+
listen <%= fetch(:nginx_ssl_port) %>;
|
122
|
+
client_max_body_size 500M;
|
123
|
+
server_name <%= fetch(:server_names) %>;
|
124
|
+
ssl on;
|
125
|
+
ssl_certificate <%= fetch(:nginx_ssl_public_crt) %>;
|
126
|
+
ssl_certificate_key <%= fetch(:nginx_ssl_private_key) %>;
|
127
|
+
ssl_session_timeout 5m;
|
128
|
+
client_max_body_size <%= fetch(:nginx_ssl_client_max_body_size) %>;
|
129
|
+
|
130
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
131
|
+
access_log <%= fetch(:nginx_log_path) %>;
|
132
|
+
error_log <%= fetch(:nginx_log_path) %> info;
|
133
|
+
|
134
|
+
# this rewrites all the requests to the maintenance.html
|
135
|
+
# page if it exists in the doc root. This is for capistrano's
|
136
|
+
# disable web task
|
137
|
+
if (-f $document_root/system/maintenance.html) {
|
138
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
139
|
+
break;
|
140
|
+
}
|
141
|
+
|
142
|
+
location / {
|
143
|
+
<% if fetch(:nginx_ssl_use_simple_auth) %>
|
144
|
+
auth_basic "<%= fetch(:nginx_simple_auth_message) %>";
|
145
|
+
auth_basic_user_file <%= fetch(:nginx_remote_htpasswd) %>;
|
146
|
+
<% end %>
|
147
|
+
|
148
|
+
# needed to forward user's IP address to rails
|
149
|
+
proxy_set_header X-Real-IP $remote_addr;
|
150
|
+
|
151
|
+
# needed for HTTPS
|
152
|
+
proxy_set_header X_FORWARDED_PROTO https;
|
153
|
+
|
154
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
155
|
+
proxy_set_header Host $http_host;
|
156
|
+
proxy_redirect off;
|
157
|
+
proxy_max_temp_file_size 0;
|
158
|
+
|
159
|
+
# if the request is for a static resource, nginx should serve it directly
|
160
|
+
# and add a far future expires header to it, making the browser
|
161
|
+
# cache the resource and navigate faster over the website.
|
162
|
+
location ~ ^/(assets)/.+-([0-9a-zA-Z])+\. {
|
163
|
+
gzip_static on;
|
164
|
+
expires max;
|
165
|
+
add_header Cache-Control public;
|
166
|
+
}
|
167
|
+
|
168
|
+
# Serve images outside the asset path
|
169
|
+
# Now this supposedly should work as it gets the filenames with querystrings that Rails provides.
|
170
|
+
# BUT there's a chance it could break the ajax calls.
|
171
|
+
location ~* \.(ico|css|gif|jpe?g|png)(\?[0-9]+)?$ {
|
172
|
+
expires max;
|
173
|
+
}
|
174
|
+
|
175
|
+
# Serve javascript outside the asset path
|
176
|
+
location ~ ^/javascripts/.*\.js(\?[0-9]+)?$ {
|
177
|
+
expires max;
|
178
|
+
}
|
179
|
+
|
180
|
+
# If the file exists as a static file serve it directly without
|
181
|
+
# running all the other rewite tests on it
|
182
|
+
if (-f $request_filename) {
|
183
|
+
break;
|
184
|
+
}
|
185
|
+
|
186
|
+
# check for index.html for directory index
|
187
|
+
# if its there on the filesystem then rewite
|
188
|
+
# the url to add /index.html to the end of it
|
189
|
+
# and then break to send it to the next config rules.
|
190
|
+
if (-f $request_filename/index.html) {
|
191
|
+
rewrite (.*) $1/index.html break;
|
192
|
+
}
|
193
|
+
|
194
|
+
# this is the meat of the rails page caching config
|
195
|
+
# it adds .html to the end of the url and then checks
|
196
|
+
# the filesystem for that file. If it exists, then we
|
197
|
+
# rewite the url to have explicit .html on the end
|
198
|
+
# and then send it on its way to the next config rule.
|
199
|
+
# if there is no file on the fs then it sets all the
|
200
|
+
# necessary headers and proxies to our upstream mongrels
|
201
|
+
if (-f $request_filename.html) {
|
202
|
+
rewrite (.*) $1.html break;
|
203
|
+
}
|
204
|
+
|
205
|
+
if (!-f $request_filename) {
|
206
|
+
proxy_pass http://<%= upstream_name_ssl %>;
|
207
|
+
break;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
error_page 500 502 503 504 /500.html;
|
212
|
+
location = /500.html {
|
213
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
<% end %>
|
@@ -10,7 +10,8 @@
|
|
10
10
|
# placed in /etc/init.d.
|
11
11
|
### END INIT INFO
|
12
12
|
|
13
|
-
# Author: Darío Javier Cravero <dario@exordo.com>
|
13
|
+
# Author: Darío Javier Cravero <'dario@exordo.com'>
|
14
|
+
# Modified by: Abdelkader Boudih <'terminale@gmail.com'>
|
14
15
|
#
|
15
16
|
# Do NOT "set -e"
|
16
17
|
|
@@ -59,7 +60,7 @@ do_start_one() {
|
|
59
60
|
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
60
61
|
do_start_one_do $1 $2
|
61
62
|
else
|
62
|
-
do_restart_one $1
|
63
|
+
do_restart_one $1 $2
|
63
64
|
fi
|
64
65
|
else
|
65
66
|
do_start_one_do $1 $2
|
@@ -70,7 +71,7 @@ do_start_one_do() {
|
|
70
71
|
log_daemon_msg "--> Woke up puma $1"
|
71
72
|
log_daemon_msg "user $2"
|
72
73
|
log_daemon_msg "log to $4"
|
73
|
-
log_daemon_msg "start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA
|
74
|
+
log_daemon_msg "start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA $1 "
|
74
75
|
start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1
|
75
76
|
}
|
76
77
|
|
@@ -81,7 +82,8 @@ do_stop() {
|
|
81
82
|
log_daemon_msg "=> Putting all the beasts to bed..."
|
82
83
|
for i in $JUNGLE; do
|
83
84
|
dir=`echo $i | cut -d , -f 1`
|
84
|
-
|
85
|
+
user=`echo $i | cut -d , -f 2`
|
86
|
+
do_stop_one $dir $user
|
85
87
|
done
|
86
88
|
}
|
87
89
|
#
|
@@ -97,7 +99,7 @@ do_stop_one() {
|
|
97
99
|
log_daemon_msg "---> Puma $1 isn't running."
|
98
100
|
else
|
99
101
|
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
100
|
-
pumactl --state $STATEFILE stop
|
102
|
+
su - $2 -c "pumactl --state $STATEFILE stop"
|
101
103
|
# Many daemons don't delete their pidfiles when they exit.
|
102
104
|
rm -f $PIDFILE $STATEFILE
|
103
105
|
fi
|
@@ -113,7 +115,8 @@ do_stop_one() {
|
|
113
115
|
do_restart() {
|
114
116
|
for i in $JUNGLE; do
|
115
117
|
dir=`echo $i | cut -d , -f 1`
|
116
|
-
|
118
|
+
user=`echo $i | cut -d , -f 2`
|
119
|
+
do_restart_one $dir $user
|
117
120
|
done
|
118
121
|
}
|
119
122
|
|
@@ -127,7 +130,7 @@ do_restart_one() {
|
|
127
130
|
|
128
131
|
if [ -e $PIDFILE ]; then
|
129
132
|
log_daemon_msg "--> About to restart puma $1"
|
130
|
-
pumactl --state $dir/tmp/pids/puma.state restart
|
133
|
+
su - $2 -c "pumactl --state $dir/tmp/pids/puma.state restart"
|
131
134
|
# kill -s USR2 `cat $PIDFILE`
|
132
135
|
# TODO Check if process exist
|
133
136
|
else
|
@@ -135,8 +138,9 @@ do_restart_one() {
|
|
135
138
|
user=`echo $i | cut -d , -f 2`
|
136
139
|
config_file=`echo $i | cut -d , -f 3`
|
137
140
|
if [ "$config_file" = "" ]; then
|
138
|
-
|
139
|
-
|
141
|
+
config_file="$dir/config/puma.rb"
|
142
|
+
do_start_one $dir $user $config_file
|
143
|
+
fi
|
140
144
|
log_file=`echo $i | cut -d , -f 4`
|
141
145
|
if [ "$log_file" = "" ]; then
|
142
146
|
log_file="$dir/log/puma.log"
|
@@ -152,7 +156,8 @@ do_restart_one() {
|
|
152
156
|
do_status() {
|
153
157
|
for i in $JUNGLE; do
|
154
158
|
dir=`echo $i | cut -d , -f 1`
|
155
|
-
|
159
|
+
user=`echo $i | cut -d , -f 2`
|
160
|
+
do_status_one $dir $user
|
156
161
|
done
|
157
162
|
}
|
158
163
|
|
@@ -166,9 +171,9 @@ do_status_one() {
|
|
166
171
|
|
167
172
|
if [ -e $PIDFILE ]; then
|
168
173
|
log_daemon_msg "--> About to status puma $1"
|
169
|
-
|
170
|
-
|
171
|
-
|
174
|
+
|
175
|
+
su - $2 -c "pumactl --state $dir/tmp/pids/puma.state stats "
|
176
|
+
|
172
177
|
else
|
173
178
|
log_daemon_msg "--> $1 isn't there :(..."
|
174
179
|
fi
|
@@ -238,13 +243,9 @@ else
|
|
238
243
|
user=`echo $i | cut -d , -f 2`
|
239
244
|
config_file=`echo $i | cut -d , -f 3`
|
240
245
|
if [ "$config_file" = "" ]; then
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
if [ "$log_file" = "" ]; then
|
245
|
-
log_file="$dir/log/puma.log"
|
246
|
-
fi
|
247
|
-
do_start_one $dir $user $config_file $log_file
|
246
|
+
config_file="$dir/config/puma.rb"
|
247
|
+
|
248
|
+
do_start_one $dir $user $config_file
|
248
249
|
fi
|
249
250
|
case "$?" in
|
250
251
|
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano3-puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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: 2013-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
description: Puma integration for Capistrano 3
|
@@ -31,7 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
-
|
34
|
+
- .gitignore
|
35
35
|
- Gemfile
|
36
36
|
- LICENSE.txt
|
37
37
|
- README.md
|
@@ -41,9 +41,15 @@ files:
|
|
41
41
|
- lib/capistrano-puma.rb
|
42
42
|
- lib/capistrano/puma.rb
|
43
43
|
- lib/capistrano/puma/jungle.rb
|
44
|
+
- lib/capistrano/puma/monit.rb
|
45
|
+
- lib/capistrano/puma/nginx.rb
|
44
46
|
- lib/capistrano/puma/version.rb
|
45
47
|
- lib/capistrano/tasks/jungle.cap
|
48
|
+
- lib/capistrano/tasks/monit.cap
|
49
|
+
- lib/capistrano/tasks/nginx.cap
|
46
50
|
- lib/capistrano/tasks/puma.cap
|
51
|
+
- lib/capistrano/templates/monit.conf.erb
|
52
|
+
- lib/capistrano/templates/nginx.conf.erb
|
47
53
|
- lib/capistrano/templates/puma-deb.erb
|
48
54
|
- lib/capistrano/templates/puma-rpm.erb
|
49
55
|
- lib/capistrano/templates/puma.rb.erb
|
@@ -58,17 +64,17 @@ require_paths:
|
|
58
64
|
- lib
|
59
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
66
|
requirements:
|
61
|
-
- -
|
67
|
+
- - '>='
|
62
68
|
- !ruby/object:Gem::Version
|
63
69
|
version: '0'
|
64
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - '>='
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
requirements: []
|
70
76
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.0.
|
77
|
+
rubygems_version: 2.0.14
|
72
78
|
signing_key:
|
73
79
|
specification_version: 4
|
74
80
|
summary: Puma integration for Capistrano
|