capistrano3-puma 4.0.0 → 5.0.0.beta1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTORS.md +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -0
- data/capistrano3-puma.gemspec +1 -1
- data/lib/capistrano/puma.rb +2 -1
- data/lib/capistrano/puma/daemon.rb +13 -0
- data/lib/capistrano/puma/nginx.rb +1 -0
- data/lib/capistrano/puma/systemd.rb +19 -0
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/daemon.rake +66 -0
- data/lib/capistrano/tasks/puma.rake +0 -79
- data/lib/capistrano/tasks/systemd.rake +59 -0
- data/lib/capistrano/templates/nginx_conf.erb +5 -2
- data/lib/capistrano/templates/puma.service.erb +18 -0
- metadata +20 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9e8a658109b9d4bae5177d3fe539a2354c343904916a779cc2e9a16ad337cf2
|
4
|
+
data.tar.gz: f70546d3675eeb4fc0998574f07c75355f25e236c2f53d45a187ae75babac5c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d16d5ac8433ab8aa783efaffa734b0b8843034f349727cec57c5d9f47e247d7ef38afdcddb4f8bc08ef465c69153fc51aa94969b3c8fb85ffe40373a93665182
|
7
|
+
data.tar.gz: e8be34856e21d6ed840f9fe9d72428a11668b239f60aeb1b4ae1eff66661cb793fe284884f97a41d76dee43b0573fb55bf3acce45ea79de810f3032f1057bb12
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -26,6 +26,14 @@ And then execute:
|
|
26
26
|
install_plugin Capistrano::Puma::Monit # if you need the monit tasks
|
27
27
|
install_plugin Capistrano::Puma::Nginx # if you want to upload a nginx site template
|
28
28
|
```
|
29
|
+
You will need to select your service manager
|
30
|
+
```ruby
|
31
|
+
install_plugin Capistrano::Puma::Daemon # If you using puma daemonized (not supported in Puma 5+)
|
32
|
+
```
|
33
|
+
or
|
34
|
+
```ruby
|
35
|
+
install_plugin Capistrano::Puma::Systemd # if you use SystemD
|
36
|
+
```
|
29
37
|
|
30
38
|
To prevent loading the hooks of the plugin, add false to the load_hooks param.
|
31
39
|
```ruby
|
@@ -95,6 +103,19 @@ For Jungle tasks (beta), these options exist:
|
|
95
103
|
set :puma_run_path, '/usr/local/bin/run-puma'
|
96
104
|
```
|
97
105
|
|
106
|
+
### Systemd
|
107
|
+
|
108
|
+
Install Systemd plugin in `Capfile`:
|
109
|
+
```ruby
|
110
|
+
install_plugin Capistrano::Puma
|
111
|
+
install_plugin Capistrano::Puma::Systemd
|
112
|
+
```
|
113
|
+
|
114
|
+
To generate unit file use:
|
115
|
+
```
|
116
|
+
cap production puma:systemd:config puma:systemd:enable
|
117
|
+
```
|
118
|
+
|
98
119
|
### Multi bind
|
99
120
|
|
100
121
|
Multi-bind can be set with an array in the puma_bind variable
|
@@ -148,6 +169,7 @@ Configurable options, shown here with defaults: Please note the configuration op
|
|
148
169
|
set :nginx_ssl_certificate, "/etc/ssl/certs/#{fetch(:nginx_config_name)}.crt"
|
149
170
|
set :nginx_ssl_certificate_key, "/etc/ssl/private/#{fetch(:nginx_config_name)}.key"
|
150
171
|
set :nginx_use_ssl, false
|
172
|
+
set :nginx_use_http2, true
|
151
173
|
set :nginx_downstream_uses_ssl, false
|
152
174
|
```
|
153
175
|
|
data/capistrano3-puma.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'capistrano', '~> 3.7'
|
22
22
|
spec.add_dependency 'capistrano-bundler'
|
23
|
-
spec.add_dependency 'puma' , '
|
23
|
+
spec.add_dependency 'puma' , '>= 4.0', '< 6.0'
|
24
24
|
spec.post_install_message = %q{
|
25
25
|
All plugins need to be explicitly installed with install_plugin.
|
26
26
|
Please see README.md
|
data/lib/capistrano/puma.rb
CHANGED
@@ -89,7 +89,6 @@ module Capistrano
|
|
89
89
|
|
90
90
|
def register_hooks
|
91
91
|
after 'deploy:check', 'puma:check'
|
92
|
-
after 'deploy:finished', 'puma:smart_restart'
|
93
92
|
end
|
94
93
|
|
95
94
|
def puma_workers
|
@@ -117,6 +116,8 @@ module Capistrano
|
|
117
116
|
end
|
118
117
|
|
119
118
|
require 'capistrano/puma/workers'
|
119
|
+
require 'capistrano/puma/daemon'
|
120
|
+
require 'capistrano/puma/systemd'
|
120
121
|
require 'capistrano/puma/monit'
|
121
122
|
require 'capistrano/puma/jungle'
|
122
123
|
require 'capistrano/puma/nginx'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Capistrano
|
2
|
+
class Puma::Daemon < Capistrano::Plugin
|
3
|
+
include PumaCommon
|
4
|
+
|
5
|
+
def register_hooks
|
6
|
+
after 'deploy:finished', 'puma:smart_restart'
|
7
|
+
end
|
8
|
+
|
9
|
+
def define_tasks
|
10
|
+
eval_rakefile File.expand_path('../../tasks/daemon.rake', __FILE__)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -11,6 +11,7 @@ module Capistrano
|
|
11
11
|
set_if_empty :nginx_http_flags, fetch(:nginx_flags)
|
12
12
|
set_if_empty :nginx_socket_flags, fetch(:nginx_flags)
|
13
13
|
set_if_empty :nginx_use_ssl, false
|
14
|
+
set_if_empty :nginx_use_http2, true
|
14
15
|
set_if_empty :nginx_downstream_uses_ssl, false
|
15
16
|
end
|
16
17
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Capistrano
|
2
|
+
class Puma::Systemd < Capistrano::Plugin
|
3
|
+
include PumaCommon
|
4
|
+
|
5
|
+
def register_hooks
|
6
|
+
after 'deploy:finished', 'puma:restart'
|
7
|
+
end
|
8
|
+
|
9
|
+
def define_tasks
|
10
|
+
eval_rakefile File.expand_path('../../tasks/systemd.rake', __FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_defaults
|
14
|
+
set_if_empty :puma_systemd_conf_dir, '/etc/systemd/system'
|
15
|
+
set_if_empty :puma_systemctl_bin, '/bin/systemctl'
|
16
|
+
set_if_empty :puma_service_unit_name, 'puma'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
git_plugin = self
|
2
|
+
|
3
|
+
namespace :puma do
|
4
|
+
desc 'Start puma'
|
5
|
+
task :start do
|
6
|
+
on roles(fetch(:puma_role)) do |role|
|
7
|
+
git_plugin.puma_switch_user(role) do
|
8
|
+
if test "[ -f #{fetch(:puma_pid)} ]" and test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
9
|
+
info 'Puma is already running'
|
10
|
+
else
|
11
|
+
within current_path do
|
12
|
+
with rack_env: fetch(:puma_env) do
|
13
|
+
execute :puma, "-C #{fetch(:puma_conf)} --daemon"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
%w[halt stop status].map do |command|
|
22
|
+
desc "#{command} puma"
|
23
|
+
task command do
|
24
|
+
on roles (fetch(:puma_role)) do |role|
|
25
|
+
within current_path do
|
26
|
+
git_plugin.puma_switch_user(role) do
|
27
|
+
with rack_env: fetch(:puma_env) do
|
28
|
+
if test "[ -f #{fetch(:puma_pid)} ]"
|
29
|
+
if test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
30
|
+
execute :pumactl, "-S #{fetch(:puma_state)} -F #{fetch(:puma_conf)} #{command}"
|
31
|
+
else
|
32
|
+
# delete invalid pid file , process is not running.
|
33
|
+
execute :rm, fetch(:puma_pid)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
#pid file not found, so puma is probably not running or it using another pidfile
|
37
|
+
warn 'Puma not running'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
%w[phased-restart restart].map do |command|
|
47
|
+
desc "#{command} puma"
|
48
|
+
task command do
|
49
|
+
on roles (fetch(:puma_role)) do |role|
|
50
|
+
within current_path do
|
51
|
+
git_plugin.puma_switch_user(role) do
|
52
|
+
with rack_env: fetch(:puma_env) do
|
53
|
+
if test "[ -f #{fetch(:puma_pid)} ]" and test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
54
|
+
# NOTE pid exist but state file is nonsense, so ignore that case
|
55
|
+
execute :pumactl, "-S #{fetch(:puma_state)} -F #{fetch(:puma_conf)} #{command}"
|
56
|
+
else
|
57
|
+
# Puma is not running or state file is not present : Run it
|
58
|
+
invoke 'puma:start'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -8,75 +8,6 @@ namespace :puma do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
desc 'Start puma'
|
12
|
-
task :start do
|
13
|
-
on roles(fetch(:puma_role)) do |role|
|
14
|
-
git_plugin.puma_switch_user(role) do
|
15
|
-
if test "[ -f #{fetch(:puma_conf)} ]"
|
16
|
-
info "using conf file #{fetch(:puma_conf)}"
|
17
|
-
else
|
18
|
-
invoke 'puma:config'
|
19
|
-
end
|
20
|
-
|
21
|
-
if test "[ -f #{fetch(:puma_pid)} ]" and test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
22
|
-
info 'Already Puma is running'
|
23
|
-
else
|
24
|
-
within current_path do
|
25
|
-
with rack_env: fetch(:puma_env) do
|
26
|
-
execute :puma, "-C #{fetch(:puma_conf)} --daemon"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
%w[halt stop status].map do |command|
|
35
|
-
desc "#{command} puma"
|
36
|
-
task command do
|
37
|
-
on roles (fetch(:puma_role)) do |role|
|
38
|
-
within current_path do
|
39
|
-
git_plugin.puma_switch_user(role) do
|
40
|
-
with rack_env: fetch(:puma_env) do
|
41
|
-
if test "[ -f #{fetch(:puma_pid)} ]"
|
42
|
-
if test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
43
|
-
execute :pumactl, "-S #{fetch(:puma_state)} -F #{fetch(:puma_conf)} #{command}"
|
44
|
-
else
|
45
|
-
# delete invalid pid file , process is not running.
|
46
|
-
execute :rm, fetch(:puma_pid)
|
47
|
-
end
|
48
|
-
else
|
49
|
-
#pid file not found, so puma is probably not running or it using another pidfile
|
50
|
-
warn 'Puma not running'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
%w[phased-restart restart].map do |command|
|
60
|
-
desc "#{command} puma"
|
61
|
-
task command do
|
62
|
-
on roles (fetch(:puma_role)) do |role|
|
63
|
-
within current_path do
|
64
|
-
git_plugin.puma_switch_user(role) do
|
65
|
-
with rack_env: fetch(:puma_env) do
|
66
|
-
if test "[ -f #{fetch(:puma_pid)} ]" and test :kill, "-0 $( cat #{fetch(:puma_pid)} )"
|
67
|
-
# NOTE pid exist but state file is nonsense, so ignore that case
|
68
|
-
execute :pumactl, "-S #{fetch(:puma_state)} -F #{fetch(:puma_conf)} #{command}"
|
69
|
-
else
|
70
|
-
# Puma is not running or state file is not present : Run it
|
71
|
-
invoke 'puma:start'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
11
|
task :check do
|
81
12
|
on roles(fetch(:puma_role)) do |role|
|
82
13
|
#Create puma.rb for new deployments
|
@@ -87,14 +18,4 @@ namespace :puma do
|
|
87
18
|
end
|
88
19
|
end
|
89
20
|
end
|
90
|
-
|
91
|
-
|
92
|
-
task :smart_restart do
|
93
|
-
if !git_plugin.puma_preload_app? && git_plugin.puma_workers.to_i > 1
|
94
|
-
invoke 'puma:phased-restart'
|
95
|
-
else
|
96
|
-
invoke 'puma:restart'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
21
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
git_plugin = self
|
4
|
+
|
5
|
+
namespace :puma do
|
6
|
+
namespace :systemd do
|
7
|
+
desc 'Config Puma systemd service'
|
8
|
+
task :config do
|
9
|
+
on roles(fetch(:puma_role)) do |role|
|
10
|
+
unit_filename = "#{fetch(:puma_service_unit_name)}.service"
|
11
|
+
git_plugin.template_puma unit_filename, "#{fetch(:tmp_dir)}/#{unit_filename}", role
|
12
|
+
sudo "mv #{fetch(:tmp_dir)}/#{unit_filename} #{fetch(:puma_systemd_conf_dir)}"
|
13
|
+
sudo "#{fetch(:puma_systemctl_bin)} daemon-reload"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Enable Puma systemd service'
|
18
|
+
task :enable do
|
19
|
+
on roles(fetch(:puma_role)) do
|
20
|
+
sudo "#{fetch(:puma_systemctl_bin)} enable #{fetch(:puma_service_unit_name)}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Disable Puma systemd service'
|
25
|
+
task :disable do
|
26
|
+
on roles(fetch(:puma_role)) do
|
27
|
+
sudo "#{fetch(:puma_systemctl_bin)} disable #{fetch(:puma_service_unit_name)}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Start Puma service via systemd'
|
33
|
+
task :start do
|
34
|
+
on roles(fetch(:puma_role)) do
|
35
|
+
sudo "#{fetch(:puma_systemctl_bin)} start #{fetch(:puma_service_unit_name)}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Stop Puma service via systemd'
|
40
|
+
task :stop do
|
41
|
+
on roles(fetch(:puma_role)) do
|
42
|
+
sudo "#{fetch(:puma_systemctl_bin)} stop #{fetch(:puma_service_unit_name)}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Restart Puma service via systemd'
|
47
|
+
task :restart do
|
48
|
+
on roles(fetch(:puma_role)) do
|
49
|
+
sudo "#{fetch(:puma_systemctl_bin)} restart #{fetch(:puma_service_unit_name)}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Get Puma service status via systemd'
|
54
|
+
task :status do
|
55
|
+
on roles(fetch(:puma_role)) do
|
56
|
+
sudo "#{fetch(:puma_systemctl_bin)} status #{fetch(:puma_service_unit_name)}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -20,8 +20,11 @@ server {
|
|
20
20
|
|
21
21
|
server {
|
22
22
|
<% if fetch(:nginx_use_ssl) -%>
|
23
|
-
|
24
|
-
ssl
|
23
|
+
<% if fetch(:nginx_use_http2) -%>
|
24
|
+
listen 443 ssl http2;
|
25
|
+
<% else -%>
|
26
|
+
listen 443 ssl;
|
27
|
+
<% end -%>
|
25
28
|
<% if fetch(:nginx_ssl_certificate) -%>
|
26
29
|
ssl_certificate <%= fetch(:nginx_ssl_certificate) %>;
|
27
30
|
<% else -%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Puma HTTP Server for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
|
3
|
+
After=network.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=<%= puma_user(@role) %>
|
8
|
+
WorkingDirectory=<%= current_path %>
|
9
|
+
ExecStart=<%= SSHKit.config.command_map[:bundle] %> exec puma -C <%= fetch(:puma_conf) %>
|
10
|
+
ExecReload=/bin/kill -TSTP $MAINPID
|
11
|
+
ExecStop=/bin/kill -TERM $MAINPID
|
12
|
+
StandardOutput=append:<%= fetch(:puma_access_log) %>
|
13
|
+
StandardError=append:<%= fetch(:puma_error_log) %>
|
14
|
+
|
15
|
+
Restart=always
|
16
|
+
|
17
|
+
[Install]
|
18
|
+
WantedBy=multi-user.target
|
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:
|
4
|
+
version: 5.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: puma
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '6.0'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6.0'
|
55
61
|
description: Puma integration for Capistrano 3
|
56
62
|
email:
|
57
63
|
- Terminale@gmail.com
|
@@ -68,20 +74,25 @@ files:
|
|
68
74
|
- Rakefile
|
69
75
|
- capistrano3-puma.gemspec
|
70
76
|
- lib/capistrano/puma.rb
|
77
|
+
- lib/capistrano/puma/daemon.rb
|
71
78
|
- lib/capistrano/puma/jungle.rb
|
72
79
|
- lib/capistrano/puma/monit.rb
|
73
80
|
- lib/capistrano/puma/nginx.rb
|
81
|
+
- lib/capistrano/puma/systemd.rb
|
74
82
|
- lib/capistrano/puma/version.rb
|
75
83
|
- lib/capistrano/puma/workers.rb
|
84
|
+
- lib/capistrano/tasks/daemon.rake
|
76
85
|
- lib/capistrano/tasks/jungle.rake
|
77
86
|
- lib/capistrano/tasks/monit.rake
|
78
87
|
- lib/capistrano/tasks/nginx.rake
|
79
88
|
- lib/capistrano/tasks/puma.rake
|
89
|
+
- lib/capistrano/tasks/systemd.rake
|
80
90
|
- lib/capistrano/tasks/workers.rake
|
81
91
|
- lib/capistrano/templates/nginx_conf.erb
|
82
92
|
- lib/capistrano/templates/puma-deb.erb
|
83
93
|
- lib/capistrano/templates/puma-rpm.erb
|
84
94
|
- lib/capistrano/templates/puma.rb.erb
|
95
|
+
- lib/capistrano/templates/puma.service.erb
|
85
96
|
- lib/capistrano/templates/puma_monit.conf.erb
|
86
97
|
- lib/capistrano/templates/run-puma.erb
|
87
98
|
- lib/capistrano3-puma.rb
|
@@ -103,13 +114,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
114
|
version: 1.9.3
|
104
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
116
|
requirements:
|
106
|
-
- - "
|
117
|
+
- - ">"
|
107
118
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
119
|
+
version: 1.3.1
|
109
120
|
requirements: []
|
110
|
-
|
111
|
-
|
112
|
-
signing_key:
|
121
|
+
rubygems_version: 3.0.3
|
122
|
+
signing_key:
|
113
123
|
specification_version: 4
|
114
124
|
summary: Puma integration for Capistrano
|
115
125
|
test_files: []
|