capistrano3-puma 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +15 -0
- data/lib/capistrano/puma/systemd.rb +3 -2
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/systemd.rake +52 -9
- data/lib/capistrano/templates/nginx_conf.erb +1 -0
- data/lib/capistrano/templates/puma.rb.erb +0 -0
- data/lib/capistrano/templates/puma.service.erb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73044aaf982d12bacb545460eec4a28a80735dfda025df5ee6a7b656f63185a1
|
4
|
+
data.tar.gz: 768c19108f85c471feb7cfc341e04244af87c90ed91e59c13d44f7771269ca4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 725fa2b8f4686d644a3068d872b46b17f3f1e3e772f3efb63bcec68affbc793dc3e037220bf3c27bad86a4c8c71f492d140b51e4f6388cbd741762c4461764b8
|
7
|
+
data.tar.gz: '03186b58d6b3574bb67ebd393827704bb69f2bf90a60412ba16ae9067f4a1c91b8d5150f95143bb1525df78417ab9e3b372e8d129f11b56b2a9498446c71a15e'
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
## Changelog
|
2
|
+
- 5.0.3:
|
3
|
+
- Remove ExecStop from systemd unit file (#314)
|
4
|
+
- Systemd user service manager and lingering (#307)
|
5
|
+
- 5.0.2:
|
6
|
+
- Single name for systemd config template
|
7
|
+
- 5.0.1:
|
8
|
+
- Fix #301, Task "puma:smart_restart" not found
|
2
9
|
- 5.0.0:
|
3
10
|
- Support puma 5.0
|
4
11
|
- Support SystemD service manager
|
data/README.md
CHANGED
@@ -116,6 +116,18 @@ To generate unit file use:
|
|
116
116
|
cap production puma:systemd:config puma:systemd:enable
|
117
117
|
```
|
118
118
|
|
119
|
+
To use customize environment variables
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
set :puma_service_unit_env_file, '/etc/environment'
|
123
|
+
```
|
124
|
+
```ruby
|
125
|
+
set :puma_service_unit_env_vars, %w[
|
126
|
+
RAILSE_NV=development
|
127
|
+
PUMA_METRICS_HTTP=tcp://0.0.0.0:9393
|
128
|
+
]
|
129
|
+
```
|
130
|
+
|
119
131
|
### Multi bind
|
120
132
|
|
121
133
|
Multi-bind can be set with an array in the puma_bind variable
|
@@ -158,6 +170,9 @@ Configurable options, shown here with defaults: Please note the configuration op
|
|
158
170
|
set :puma_plugins, [] #accept array of plugins
|
159
171
|
set :puma_tag, fetch(:application)
|
160
172
|
set :puma_restart_command, 'bundle exec puma'
|
173
|
+
set :puma_service_unit_name, "puma_#{fetch(:application)}_#{fetch(:stage)}"
|
174
|
+
set :puma_service_unit_env_file, nil
|
175
|
+
set :puma_service_unit_env_vars, []
|
161
176
|
|
162
177
|
set :nginx_config_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
163
178
|
set :nginx_flags, 'fail_timeout=0'
|
@@ -11,9 +11,10 @@ module Capistrano
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def set_defaults
|
14
|
-
set_if_empty :puma_systemd_conf_dir, '/etc/systemd/system'
|
15
14
|
set_if_empty :puma_systemctl_bin, '/bin/systemctl'
|
16
|
-
set_if_empty :puma_service_unit_name,
|
15
|
+
set_if_empty :puma_service_unit_name, -> { "puma_#{fetch(:application)}_#{fetch(:stage)}" }
|
16
|
+
set_if_empty :puma_service_unit_user, :system
|
17
|
+
set_if_empty :puma_enable_lingering, false
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -8,52 +8,95 @@ namespace :puma do
|
|
8
8
|
task :config do
|
9
9
|
on roles(fetch(:puma_role)) do |role|
|
10
10
|
unit_filename = "#{fetch(:puma_service_unit_name)}.service"
|
11
|
-
git_plugin.template_puma
|
12
|
-
|
13
|
-
|
11
|
+
git_plugin.template_puma "puma.service", "#{fetch(:tmp_dir)}/#{unit_filename}", role
|
12
|
+
systemd_path = fetch(:puma_systemd_conf_dir, git_plugin.fetch_systemd_unit_path)
|
13
|
+
if fetch(:puma_systemctl_user) == :system
|
14
|
+
sudo "mv #{fetch(:tmp_dir)}/#{unit_filename} #{systemd_path}"
|
15
|
+
sudo "#{fetch(:puma_systemctl_bin)} daemon-reload"
|
16
|
+
else
|
17
|
+
execute :mkdir, "-p", systemd_path
|
18
|
+
execute :mv, "#{fetch(:tmp_dir)}/#{unit_filename}", "#{systemd_path}"
|
19
|
+
execute fetch(:puma_systemctl_bin), "--user", "daemon-reload"
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
17
24
|
desc 'Enable Puma systemd service'
|
18
25
|
task :enable do
|
19
26
|
on roles(fetch(:puma_role)) do
|
20
|
-
|
27
|
+
if fetch(:puma_systemctl_user) == :system
|
28
|
+
sudo "#{fetch(:puma_systemctl_bin)} enable #{fetch(:puma_service_unit_name)}"
|
29
|
+
else
|
30
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "enable", fetch(:puma_service_unit_name)
|
31
|
+
execute :loginctl, "enable-linger", fetch(:puma_lingering_user) if fetch(:puma_enable_lingering)
|
32
|
+
end
|
21
33
|
end
|
22
34
|
end
|
23
35
|
|
24
36
|
desc 'Disable Puma systemd service'
|
25
37
|
task :disable do
|
26
38
|
on roles(fetch(:puma_role)) do
|
27
|
-
|
39
|
+
if fetch(:puma_systemctl_user) == :system
|
40
|
+
sudo "#{fetch(:puma_systemctl_bin)} disable #{fetch(:puma_service_unit_name)}"
|
41
|
+
else
|
42
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "disable", fetch(:puma_service_unit_name)
|
43
|
+
end
|
28
44
|
end
|
29
45
|
end
|
46
|
+
|
30
47
|
end
|
31
48
|
|
32
49
|
desc 'Start Puma service via systemd'
|
33
50
|
task :start do
|
34
51
|
on roles(fetch(:puma_role)) do
|
35
|
-
|
52
|
+
if fetch(:puma_systemctl_user) == :system
|
53
|
+
sudo "#{fetch(:puma_systemctl_bin)} start #{fetch(:puma_service_unit_name)}"
|
54
|
+
else
|
55
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "start", fetch(:puma_service_unit_name)
|
56
|
+
end
|
36
57
|
end
|
37
58
|
end
|
38
59
|
|
39
60
|
desc 'Stop Puma service via systemd'
|
40
61
|
task :stop do
|
41
62
|
on roles(fetch(:puma_role)) do
|
42
|
-
|
63
|
+
if fetch(:puma_systemctl_user) == :system
|
64
|
+
sudo "#{fetch(:puma_systemctl_bin)} stop #{fetch(:puma_service_unit_name)}"
|
65
|
+
else
|
66
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "stop", fetch(:puma_service_unit_name)
|
67
|
+
end
|
43
68
|
end
|
44
69
|
end
|
45
70
|
|
46
71
|
desc 'Restart Puma service via systemd'
|
47
72
|
task :restart do
|
48
73
|
on roles(fetch(:puma_role)) do
|
49
|
-
|
74
|
+
if fetch(:puma_systemctl_user) == :system
|
75
|
+
sudo "#{fetch(:puma_systemctl_bin)} restart #{fetch(:puma_service_unit_name)}"
|
76
|
+
else
|
77
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "restart", fetch(:puma_service_unit_name)
|
78
|
+
end
|
50
79
|
end
|
51
80
|
end
|
52
81
|
|
53
82
|
desc 'Get Puma service status via systemd'
|
54
83
|
task :status do
|
55
84
|
on roles(fetch(:puma_role)) do
|
56
|
-
|
85
|
+
if fetch(:puma_systemctl_user) == :system
|
86
|
+
sudo "#{fetch(:puma_systemctl_bin)} status #{fetch(:puma_service_unit_name)}"
|
87
|
+
else
|
88
|
+
execute "#{fetch(:puma_systemctl_bin)}", "--user", "status", fetch(:puma_service_unit_name)
|
89
|
+
end
|
57
90
|
end
|
58
91
|
end
|
92
|
+
|
93
|
+
def fetch_systemd_unit_path
|
94
|
+
if fetch(:puma_systemctl_user) == :system
|
95
|
+
"/etc/systemd/system/"
|
96
|
+
else
|
97
|
+
home_dir = backend.capture :pwd
|
98
|
+
File.join(home_dir, ".config", "systemd", "user")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
59
102
|
end
|
@@ -51,6 +51,7 @@ server {
|
|
51
51
|
location @puma_<%= fetch(:nginx_config_name) %> {
|
52
52
|
proxy_http_version 1.1;
|
53
53
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
54
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
54
55
|
proxy_set_header Host $host;
|
55
56
|
proxy_redirect off;
|
56
57
|
proxy_set_header Upgrade $http_upgrade;
|
File without changes
|
@@ -4,15 +4,22 @@ After=network.target
|
|
4
4
|
|
5
5
|
[Service]
|
6
6
|
Type=simple
|
7
|
-
User
|
7
|
+
<%="User=#{puma_user(@role)}" if fetch(:puma_systemctl_user) == :system %>
|
8
8
|
WorkingDirectory=<%= current_path %>
|
9
9
|
ExecStart=<%= SSHKit.config.command_map[:bundle] %> exec puma -C <%= fetch(:puma_conf) %>
|
10
10
|
ExecReload=/bin/kill -TSTP $MAINPID
|
11
|
-
ExecStop=/bin/kill -TERM $MAINPID
|
12
11
|
StandardOutput=append:<%= fetch(:puma_access_log) %>
|
13
12
|
StandardError=append:<%= fetch(:puma_error_log) %>
|
13
|
+
<%="EnvironmentFile=#{fetch(:puma_service_unit_env_file)}" if fetch(:puma_service_unit_env_file) %>
|
14
|
+
|
15
|
+
<% fetch(:puma_service_unit_env_vars, []).each do |environment_variable| %>
|
16
|
+
<%="Environment=#{environment_variable}" %>
|
17
|
+
<% end %>
|
14
18
|
|
15
19
|
Restart=always
|
20
|
+
RestartSec=1
|
21
|
+
|
22
|
+
SyslogIdentifier=puma
|
16
23
|
|
17
24
|
[Install]
|
18
|
-
WantedBy
|
25
|
+
WantedBy=<%=(fetch(:puma_systemctl_user) == :system) ? "multi-user.target" : "default.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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|