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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2556d3d0f9c69518e9b8fff34c4e9a5414df32421c886749c5780ea76d4a29ab
4
- data.tar.gz: 346d5440671df45a98bb55b9156de333b6d75978c8370f323b8e191f87f5e84c
3
+ metadata.gz: 73044aaf982d12bacb545460eec4a28a80735dfda025df5ee6a7b656f63185a1
4
+ data.tar.gz: 768c19108f85c471feb7cfc341e04244af87c90ed91e59c13d44f7771269ca4a
5
5
  SHA512:
6
- metadata.gz: e223d91b3153aa0cd69ffb59ffa21f3ac4d49c98f006825930ad4ea385c6d89e79d61d2478af3314e583abcfc596dcef180fed80b7d2f6f7c5fa93f2169a76c1
7
- data.tar.gz: 6f1db9884b136d4595e65f7dc2bc7eb3027e8603e74e3f985b014a912ee8729c83b223a118ea37b39aa3981a82cead762fc26c959b4b171132624708400709f6
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, 'puma'
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
@@ -1,3 +1,3 @@
1
1
  module Capistrano
2
- PUMAVERSION = '5.0.2'
2
+ PUMAVERSION = '5.0.3'
3
3
  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 'puma.service', "#{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"
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
- sudo "#{fetch(:puma_systemctl_bin)} enable #{fetch(:puma_service_unit_name)}"
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
- sudo "#{fetch(:puma_systemctl_bin)} disable #{fetch(:puma_service_unit_name)}"
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
- sudo "#{fetch(:puma_systemctl_bin)} start #{fetch(:puma_service_unit_name)}"
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
- sudo "#{fetch(:puma_systemctl_bin)} stop #{fetch(:puma_service_unit_name)}"
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
- sudo "#{fetch(:puma_systemctl_bin)} restart #{fetch(:puma_service_unit_name)}"
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
- sudo "#{fetch(:puma_systemctl_bin)} status #{fetch(:puma_service_unit_name)}"
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=<%= puma_user(@role) %>
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=multi-user.target
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.2
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: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano