capistrano3-puma 5.2.0 → 6.0.0.alpha.1
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/LICENSE.txt +1 -1
- data/README.md +1 -51
- data/lib/capistrano/puma/systemd.rb +9 -4
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/puma.rb +1 -52
- data/lib/capistrano/tasks/systemd.rake +63 -61
- data/lib/capistrano/templates/puma.service.erb +20 -8
- data/lib/capistrano/templates/puma_monit.conf.erb +1 -1
- data/lib/generators/capistrano/nginx_puma/config_generator.rb +0 -1
- metadata +10 -25
- data/.github/workflows/stale.yml +0 -19
- data/.gitignore +0 -18
- data/CONTRIBUTORS.md +0 -48
- data/Gemfile +0 -8
- data/Rakefile +0 -9
- data/capistrano3-puma.gemspec +0 -28
- data/lib/capistrano/puma/daemon.rb +0 -13
- data/lib/capistrano/puma/jungle.rb +0 -22
- data/lib/capistrano/puma/workers.rb +0 -9
- data/lib/capistrano/tasks/daemon.rake +0 -74
- data/lib/capistrano/tasks/jungle.rake +0 -65
- data/lib/capistrano/tasks/puma.rake +0 -21
- data/lib/capistrano/tasks/workers.rake +0 -43
- data/lib/capistrano/templates/puma.rb.erb +0 -54
- data/lib/capistrano/templates/run-puma.erb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01bd202af4ad17172fc916bf260dbf62087ea870d2a52804d064d0af0887ca2a
|
4
|
+
data.tar.gz: 59a9663b2823120f9efc4a02912bce9fd3311d82cca7e519773fd10c0bcc5560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd42b02660819d794a727b823cf2971aa07aa99bf1b7ffc8b2e7437c8994beec8526eab86395e76c9ce99778c214b281488fc656f870affce42f09ea35a3216
|
7
|
+
data.tar.gz: 56f3da4144e37e077f992053782a3bedfff7927b3dff4ff5a10e4ac550c0cbeb5684a7472273108218f4a3b48e8d91d9b0c97f20ecb875915922675233284db9
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -21,19 +21,10 @@ And then execute:
|
|
21
21
|
|
22
22
|
require 'capistrano/puma'
|
23
23
|
install_plugin Capistrano::Puma # Default puma tasks
|
24
|
-
install_plugin Capistrano::Puma::
|
25
|
-
install_plugin Capistrano::Puma::Jungle # if you need the jungle tasks
|
24
|
+
install_plugin Capistrano::Puma::Systemd
|
26
25
|
install_plugin Capistrano::Puma::Monit # if you need the monit tasks
|
27
26
|
install_plugin Capistrano::Puma::Nginx # if you want to upload a nginx site template
|
28
27
|
```
|
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
|
-
```
|
37
28
|
|
38
29
|
To prevent loading the hooks of the plugin, add false to the load_hooks param.
|
39
30
|
```ruby
|
@@ -95,27 +86,6 @@ or define a standalone one:
|
|
95
86
|
role :puma_nginx, %w{root@example.com}
|
96
87
|
```
|
97
88
|
|
98
|
-
### Jungle
|
99
|
-
|
100
|
-
For Jungle tasks (beta), these options exist:
|
101
|
-
```ruby
|
102
|
-
set :puma_jungle_conf, '/etc/puma.conf'
|
103
|
-
set :puma_run_path, '/usr/local/bin/run-puma'
|
104
|
-
```
|
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
|
-
|
119
89
|
To use customize environment variables
|
120
90
|
|
121
91
|
```ruby
|
@@ -172,33 +142,13 @@ Configurable options, shown here with defaults: Please note the configuration op
|
|
172
142
|
|
173
143
|
```ruby
|
174
144
|
set :puma_user, fetch(:user)
|
175
|
-
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
|
176
|
-
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
|
177
|
-
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
|
178
|
-
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" #accept array for multi-bind
|
179
|
-
set :puma_control_app, false
|
180
|
-
set :puma_default_control_app, "unix://#{shared_path}/tmp/sockets/pumactl.sock"
|
181
|
-
set :puma_conf, "#{shared_path}/puma.rb"
|
182
|
-
set :puma_access_log, "#{shared_path}/log/puma_access.log"
|
183
|
-
set :puma_error_log, "#{shared_path}/log/puma_error.log"
|
184
145
|
set :puma_role, :app
|
185
|
-
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
|
186
|
-
set :puma_threads, [0, 16]
|
187
|
-
set :puma_workers, 0
|
188
|
-
set :puma_worker_timeout, nil
|
189
|
-
set :puma_init_active_record, false
|
190
|
-
set :puma_preload_app, false
|
191
|
-
set :puma_daemonize, false
|
192
|
-
set :puma_plugins, [] #accept array of plugins
|
193
|
-
set :puma_tag, fetch(:application)
|
194
|
-
set :puma_restart_command, 'bundle exec puma'
|
195
146
|
set :puma_service_unit_name, "puma_#{fetch(:application)}_#{fetch(:stage)}"
|
196
147
|
set :puma_systemctl_user, :system # accepts :user
|
197
148
|
set :puma_enable_lingering, fetch(:puma_systemctl_user) != :system # https://wiki.archlinux.org/index.php/systemd/User#Automatic_start-up_of_systemd_user_instances
|
198
149
|
set :puma_lingering_user, fetch(:user)
|
199
150
|
set :puma_service_unit_env_file, nil
|
200
151
|
set :puma_service_unit_env_vars, []
|
201
|
-
set :puma_phased_restart, false
|
202
152
|
|
203
153
|
set :nginx_config_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
204
154
|
set :nginx_flags, 'fail_timeout=0'
|
@@ -11,13 +11,18 @@ module Capistrano
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def set_defaults
|
14
|
-
set_if_empty :puma_systemctl_bin, '/bin/systemctl'
|
14
|
+
set_if_empty :puma_systemctl_bin, -> { fetch(:systemctl_bin, '/bin/systemctl') }
|
15
15
|
set_if_empty :puma_service_unit_name, -> { "puma_#{fetch(:application)}_#{fetch(:stage)}" }
|
16
16
|
set_if_empty :puma_enable_socket_service, -> { false }
|
17
|
-
set_if_empty :puma_systemctl_user, :system
|
18
|
-
set_if_empty :puma_enable_lingering, -> { fetch(:puma_systemctl_user) != :system }
|
19
|
-
set_if_empty :puma_lingering_user, -> { fetch(:user) }
|
20
17
|
set_if_empty :puma_phased_restart, -> { false }
|
18
|
+
|
19
|
+
set_if_empty :puma_systemctl_user, -> { fetch(:systemctl_user, :user) }
|
20
|
+
set_if_empty :puma_enable_lingering, -> { fetch(:puma_systemctl_user) != :system }
|
21
|
+
set_if_empty :puma_lingering_user, -> { fetch(:lingering_user, fetch(:user)) }
|
22
|
+
set_if_empty :puma_access_log, -> { File.join(shared_path, 'log', "#{fetch(:puma_env)}.log") }
|
23
|
+
set_if_empty :puma_error_log, -> { File.join(shared_path, 'log', "#{fetch(:puma_env)}.log") }
|
24
|
+
|
25
|
+
set_if_empty :puma_service_templates_path, fetch(:service_templates_path, 'config/deploy/templates')
|
21
26
|
end
|
22
27
|
|
23
28
|
def expanded_bundle_command
|
data/lib/capistrano/puma.rb
CHANGED
@@ -44,7 +44,7 @@ module Capistrano
|
|
44
44
|
File.expand_path("../templates/#{from}.rb.erb", __FILE__)
|
45
45
|
].detect { |path| File.file?(path) }
|
46
46
|
erb = File.read(file)
|
47
|
-
StringIO.new(ERB.new(erb,
|
47
|
+
StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
|
48
48
|
end
|
49
49
|
|
50
50
|
def template_puma(from, to, role)
|
@@ -94,31 +94,9 @@ module Capistrano
|
|
94
94
|
class Puma < Capistrano::Plugin
|
95
95
|
include PumaCommon
|
96
96
|
|
97
|
-
def define_tasks
|
98
|
-
eval_rakefile File.expand_path('../tasks/puma.rake', __FILE__)
|
99
|
-
end
|
100
|
-
|
101
97
|
def set_defaults
|
102
98
|
set_if_empty :puma_role, :app
|
103
99
|
set_if_empty :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
|
104
|
-
# Configure "min" to be the minimum number of threads to use to answer
|
105
|
-
# requests and "max" the maximum.
|
106
|
-
set_if_empty :puma_threads, [0, 16]
|
107
|
-
set_if_empty :puma_workers, 0
|
108
|
-
set_if_empty :puma_rackup, -> { File.join(current_path, 'config.ru') }
|
109
|
-
set_if_empty :puma_state, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
|
110
|
-
set_if_empty :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
111
|
-
set_if_empty :puma_bind, -> { File.join("unix://#{shared_path}", 'tmp', 'sockets', 'puma.sock') }
|
112
|
-
set_if_empty :puma_control_app, false
|
113
|
-
set_if_empty :puma_default_control_app, -> { File.join("unix://#{shared_path}", 'tmp', 'sockets', 'pumactl.sock') }
|
114
|
-
set_if_empty :puma_conf, -> { File.join(shared_path, 'puma.rb') }
|
115
|
-
set_if_empty :puma_access_log, -> { File.join(shared_path, 'log', 'puma_access.log') }
|
116
|
-
set_if_empty :puma_error_log, -> { File.join(shared_path, 'log', 'puma_error.log') }
|
117
|
-
set_if_empty :puma_init_active_record, false
|
118
|
-
set_if_empty :puma_preload_app, false
|
119
|
-
set_if_empty :puma_daemonize, false
|
120
|
-
set_if_empty :puma_tag, ''
|
121
|
-
set_if_empty :puma_restart_command, 'bundle exec puma'
|
122
100
|
|
123
101
|
# Chruby, Rbenv and RVM integration
|
124
102
|
append :chruby_map_bins, 'puma', 'pumactl'
|
@@ -128,38 +106,9 @@ module Capistrano
|
|
128
106
|
# Bundler integration
|
129
107
|
append :bundle_bins, 'puma', 'pumactl'
|
130
108
|
end
|
131
|
-
|
132
|
-
def register_hooks
|
133
|
-
after 'deploy:check', 'puma:check'
|
134
|
-
end
|
135
|
-
|
136
|
-
def puma_workers
|
137
|
-
fetch(:puma_workers, 0)
|
138
|
-
end
|
139
|
-
|
140
|
-
def puma_preload_app?
|
141
|
-
fetch(:puma_preload_app)
|
142
|
-
end
|
143
|
-
|
144
|
-
def puma_daemonize?
|
145
|
-
fetch(:puma_daemonize)
|
146
|
-
end
|
147
|
-
|
148
|
-
def puma_plugins
|
149
|
-
Array(fetch(:puma_plugins)).collect do |bind|
|
150
|
-
"plugin '#{bind}'"
|
151
|
-
end.join("\n")
|
152
|
-
end
|
153
|
-
|
154
|
-
def upload_puma_rb(role)
|
155
|
-
template_puma 'puma', fetch(:puma_conf), role
|
156
|
-
end
|
157
109
|
end
|
158
110
|
end
|
159
111
|
|
160
|
-
require 'capistrano/puma/workers'
|
161
|
-
require 'capistrano/puma/daemon'
|
162
112
|
require 'capistrano/puma/systemd'
|
163
113
|
require 'capistrano/puma/monit'
|
164
|
-
require 'capistrano/puma/jungle'
|
165
114
|
require 'capistrano/puma/nginx'
|
@@ -3,76 +3,64 @@
|
|
3
3
|
git_plugin = self
|
4
4
|
|
5
5
|
namespace :puma do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
execute :mv, "#{fetch(:tmp_dir)}/#{unit_filename}", "#{systemd_path}"
|
19
|
-
end
|
6
|
+
desc 'Install Puma systemd service'
|
7
|
+
task :install do
|
8
|
+
on roles(fetch(:puma_role)) do |role|
|
9
|
+
|
10
|
+
upload_compiled_template = lambda do |template_name, unit_filename|
|
11
|
+
git_plugin.template_puma template_name, "#{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
|
+
else
|
16
|
+
execute :mkdir, "-p", systemd_path
|
17
|
+
execute :mv, "#{fetch(:tmp_dir)}/#{unit_filename}", "#{systemd_path}"
|
20
18
|
end
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
if fetch(:puma_enable_socket_service)
|
25
|
-
upload_compiled_template.call("puma.socket", "#{fetch(:puma_service_unit_name)}.socket")
|
26
|
-
end
|
21
|
+
upload_compiled_template.call("puma.service", "#{fetch(:puma_service_unit_name)}.service")
|
27
22
|
|
28
|
-
|
29
|
-
|
23
|
+
if fetch(:puma_enable_socket_service)
|
24
|
+
upload_compiled_template.call("puma.socket", "#{fetch(:puma_service_unit_name)}.socket")
|
30
25
|
end
|
31
|
-
end
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
fake_role = Struct.new(:hostname)
|
36
|
-
run_locally do
|
37
|
-
File.write('puma.service', git_plugin.compiled_template_puma("puma.service", fake_role.new("example.com")).string)
|
38
|
-
if fetch(:puma_enable_socket_service)
|
39
|
-
File.write('puma.socket', git_plugin.compiled_template_puma("puma.socket", fake_role.new("example.com")).string)
|
40
|
-
end
|
41
|
-
end
|
27
|
+
# Reload systemd
|
28
|
+
git_plugin.execute_systemd("daemon-reload")
|
42
29
|
end
|
30
|
+
end
|
43
31
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
32
|
+
desc 'Uninstall Puma systemd service'
|
33
|
+
task :uninstall do
|
34
|
+
invoke 'puma:disable'
|
35
|
+
on roles(fetch(:puma_role)) do |role|
|
36
|
+
systemd_path = fetch(:puma_systemd_conf_dir, git_plugin.fetch_systemd_unit_path)
|
37
|
+
if fetch(:puma_systemctl_user) == :system
|
38
|
+
sudo "rm -f #{systemd_path}/#{fetch(:puma_service_unit_name)}*"
|
39
|
+
else
|
40
|
+
execute :rm, "-f", "#{systemd_path}/#{fetch(:puma_service_unit_name)}*"
|
53
41
|
end
|
42
|
+
git_plugin.execute_systemd("daemon-reload")
|
54
43
|
end
|
55
44
|
|
56
|
-
|
57
|
-
task :disable do
|
58
|
-
on roles(fetch(:puma_role)) do
|
59
|
-
git_plugin.execute_systemd("disable", fetch(:puma_service_unit_name))
|
60
|
-
git_plugin.execute_systemd("disable", fetch(:puma_service_unit_name) + ".socket") if fetch(:puma_enable_socket_service)
|
61
|
-
end
|
62
|
-
end
|
45
|
+
end
|
63
46
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
47
|
+
desc 'Enable Puma systemd service'
|
48
|
+
task :enable do
|
49
|
+
on roles(fetch(:puma_role)) do
|
50
|
+
git_plugin.execute_systemd("enable", fetch(:puma_service_unit_name))
|
51
|
+
git_plugin.execute_systemd("enable", fetch(:puma_service_unit_name) + ".socket") if fetch(:puma_enable_socket_service)
|
52
|
+
|
53
|
+
if fetch(:puma_systemctl_user) != :system && fetch(:puma_enable_lingering)
|
54
|
+
execute :loginctl, "enable-linger", fetch(:puma_lingering_user)
|
68
55
|
end
|
69
56
|
end
|
57
|
+
end
|
70
58
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
59
|
+
desc 'Disable Puma systemd service'
|
60
|
+
task :disable do
|
61
|
+
on roles(fetch(:puma_role)) do
|
62
|
+
git_plugin.execute_systemd("disable", fetch(:puma_service_unit_name))
|
63
|
+
git_plugin.execute_systemd("disable", fetch(:puma_service_unit_name) + ".socket") if fetch(:puma_enable_socket_service)
|
76
64
|
end
|
77
65
|
end
|
78
66
|
|
@@ -90,6 +78,13 @@ namespace :puma do
|
|
90
78
|
end
|
91
79
|
end
|
92
80
|
|
81
|
+
desc 'Stop Puma socket via systemd'
|
82
|
+
task :stop_socket do
|
83
|
+
on roles(fetch(:puma_role)) do
|
84
|
+
git_plugin.execute_systemd("stop", fetch(:puma_service_unit_name) + ".socket")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
93
88
|
desc 'Restarts or reloads Puma service via systemd'
|
94
89
|
task :smart_restart do
|
95
90
|
if fetch(:puma_phased_restart)
|
@@ -106,16 +101,23 @@ namespace :puma do
|
|
106
101
|
end
|
107
102
|
end
|
108
103
|
|
104
|
+
desc 'Restart Puma socket via systemd'
|
105
|
+
task :restart_socket do
|
106
|
+
on roles(fetch(:puma_role)) do
|
107
|
+
git_plugin.execute_systemd("restart", fetch(:puma_service_unit_name) + ".socket")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
109
111
|
desc 'Reload Puma service via systemd'
|
110
112
|
task :reload do
|
111
113
|
on roles(fetch(:puma_role)) do
|
112
114
|
service_ok = if fetch(:puma_systemctl_user) == :system
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
115
|
+
execute("#{fetch(:puma_systemctl_bin)} status #{fetch(:puma_service_unit_name)} > /dev/null", raise_on_non_zero_exit: false)
|
116
|
+
else
|
117
|
+
execute("#{fetch(:puma_systemctl_bin)} --user status #{fetch(:puma_service_unit_name)} > /dev/null", raise_on_non_zero_exit: false)
|
118
|
+
end
|
117
119
|
cmd = 'reload'
|
118
|
-
|
120
|
+
unless service_ok
|
119
121
|
cmd = 'restart'
|
120
122
|
end
|
121
123
|
if fetch(:puma_systemctl_user) == :system
|
@@ -1,28 +1,40 @@
|
|
1
|
+
# This file tells systemd how to run Puma as a 24/7 long-running daemon.
|
2
|
+
#
|
3
|
+
# Customize this file based on your bundler location, app directory, etc.
|
4
|
+
# Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
|
5
|
+
# Then run:
|
6
|
+
# - systemctl enable <%= fetch(:puma_service_unit_name) %>
|
7
|
+
# - systemctl {start,stop,restart} <%= fetch(:puma_service_unit_name) %>
|
8
|
+
#
|
9
|
+
#
|
10
|
+
# Use `journalctl -u <%= fetch(:puma_service_unit_name) %> -rn 100` to view the last 100 lines of log output.
|
11
|
+
#
|
1
12
|
[Unit]
|
2
13
|
Description=Puma HTTP Server for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
|
3
14
|
After=network.target
|
4
15
|
<%= "Requires=#{fetch(:puma_service_unit_name)}.socket" if fetch(:puma_enable_socket_service) %>
|
16
|
+
After=syslog.target network.target
|
5
17
|
|
6
18
|
[Service]
|
7
19
|
Type=simple
|
8
|
-
<%="User=#{puma_user(@role)}" if fetch(:puma_systemctl_user) == :system
|
20
|
+
<%="User=#{puma_user(@role)}" if fetch(:puma_systemctl_user) == :system -%>
|
9
21
|
WorkingDirectory=<%= current_path %>
|
10
22
|
# Support older bundler versions where file descriptors weren't kept
|
11
23
|
# See https://github.com/rubygems/rubygems/issues/3254
|
12
|
-
ExecStart=<%= expanded_bundle_command %> exec --keep-file-descriptors puma
|
24
|
+
ExecStart=<%= expanded_bundle_command %> exec --keep-file-descriptors puma
|
13
25
|
ExecReload=/bin/kill -USR1 $MAINPID
|
14
|
-
StandardOutput=append:<%= fetch(:puma_access_log) %>
|
15
|
-
StandardError=append:<%= fetch(:puma_error_log) %>
|
16
|
-
<%="EnvironmentFile=#{fetch(:puma_service_unit_env_file)}" if fetch(:puma_service_unit_env_file) %>
|
17
26
|
|
27
|
+
<%="EnvironmentFile=#{fetch(:puma_service_unit_env_file)}" if fetch(:puma_service_unit_env_file) %>
|
18
28
|
<% fetch(:puma_service_unit_env_vars, []).each do |environment_variable| %>
|
19
29
|
<%="Environment=#{environment_variable}" %>
|
20
30
|
<% end %>
|
21
|
-
|
22
|
-
Restart=always
|
31
|
+
# if we crash, restart
|
23
32
|
RestartSec=1
|
33
|
+
Restart=on-failure
|
24
34
|
|
25
|
-
|
35
|
+
<%="StandardOutput=append:#{fetch(:puma_access_log)}" if fetch(:puma_access_log) %>
|
36
|
+
<%="StandardError=append:#{fetch(:puma_error_log)}" if fetch(:puma_error_log) %>
|
26
37
|
|
38
|
+
SyslogIdentifier=<%= fetch(:puma_service_unit_name) %>
|
27
39
|
[Install]
|
28
40
|
WantedBy=<%=(fetch(:puma_systemctl_user) == :system) ? "multi-user.target" : "default.target"%>
|
@@ -3,5 +3,5 @@
|
|
3
3
|
#
|
4
4
|
check process <%= puma_monit_service_name %>
|
5
5
|
with pidfile "<%= fetch(:puma_pid) %>"
|
6
|
-
start program = "/usr/bin/sudo -iu <%= puma_user(@role) %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:puma] %>
|
6
|
+
start program = "/usr/bin/sudo -iu <%= puma_user(@role) %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:puma] %> %> --daemon'"
|
7
7
|
stop program = "/usr/bin/sudo -iu <%= puma_user(@role) %> /bin/bash -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:pumactl] %> -S <%= fetch(:puma_state) %> stop'"
|
@@ -9,7 +9,6 @@ module Capistrano
|
|
9
9
|
:banner => "path to templates"
|
10
10
|
|
11
11
|
def copy_template
|
12
|
-
copy_file "../../../../capistrano/templates/puma.rb.erb", "#{templates_path}/puma.rb.erb"
|
13
12
|
copy_file "../../../../capistrano/templates/nginx_conf.erb", "#{templates_path}/nginx_conf.erb"
|
14
13
|
# copy_file "puma.rb.erb", "#{templates_path}/puma.rb.erb"
|
15
14
|
# copy_file "puma_init.erb", "#{templates_path}/puma_init.erb"
|
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: 6.0.0.alpha.1
|
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: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.0'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '6.0'
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '5.0'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '6.0'
|
@@ -65,38 +65,23 @@ executables: []
|
|
65
65
|
extensions: []
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
|
-
- ".github/workflows/stale.yml"
|
69
|
-
- ".gitignore"
|
70
68
|
- CHANGELOG.md
|
71
|
-
- CONTRIBUTORS.md
|
72
|
-
- Gemfile
|
73
69
|
- LICENSE.txt
|
74
70
|
- README.md
|
75
|
-
- Rakefile
|
76
|
-
- capistrano3-puma.gemspec
|
77
71
|
- lib/capistrano/puma.rb
|
78
|
-
- lib/capistrano/puma/daemon.rb
|
79
|
-
- lib/capistrano/puma/jungle.rb
|
80
72
|
- lib/capistrano/puma/monit.rb
|
81
73
|
- lib/capistrano/puma/nginx.rb
|
82
74
|
- lib/capistrano/puma/systemd.rb
|
83
75
|
- lib/capistrano/puma/version.rb
|
84
|
-
- lib/capistrano/puma/workers.rb
|
85
|
-
- lib/capistrano/tasks/daemon.rake
|
86
|
-
- lib/capistrano/tasks/jungle.rake
|
87
76
|
- lib/capistrano/tasks/monit.rake
|
88
77
|
- lib/capistrano/tasks/nginx.rake
|
89
|
-
- lib/capistrano/tasks/puma.rake
|
90
78
|
- lib/capistrano/tasks/systemd.rake
|
91
|
-
- lib/capistrano/tasks/workers.rake
|
92
79
|
- lib/capistrano/templates/nginx_conf.erb
|
93
80
|
- lib/capistrano/templates/puma-deb.erb
|
94
81
|
- lib/capistrano/templates/puma-rpm.erb
|
95
|
-
- lib/capistrano/templates/puma.rb.erb
|
96
82
|
- lib/capistrano/templates/puma.service.erb
|
97
83
|
- lib/capistrano/templates/puma.socket.erb
|
98
84
|
- lib/capistrano/templates/puma_monit.conf.erb
|
99
|
-
- lib/capistrano/templates/run-puma.erb
|
100
85
|
- lib/capistrano3-puma.rb
|
101
86
|
- lib/generators/capistrano/nginx_puma/USAGE
|
102
87
|
- lib/generators/capistrano/nginx_puma/config_generator.rb
|
@@ -104,8 +89,8 @@ homepage: https://github.com/seuros/capistrano-puma
|
|
104
89
|
licenses:
|
105
90
|
- MIT
|
106
91
|
metadata: {}
|
107
|
-
post_install_message: "\n
|
108
|
-
|
92
|
+
post_install_message: "\n Version 6.0.0 is a major release. Please see README.md,
|
93
|
+
breaking changes are listed in CHANGELOG.md\n "
|
109
94
|
rdoc_options: []
|
110
95
|
require_paths:
|
111
96
|
- lib
|
@@ -113,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
98
|
requirements:
|
114
99
|
- - ">="
|
115
100
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
101
|
+
version: '2.5'
|
117
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
103
|
requirements:
|
119
|
-
- - "
|
104
|
+
- - ">"
|
120
105
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
106
|
+
version: 1.3.1
|
122
107
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.2.33
|
124
109
|
signing_key:
|
125
110
|
specification_version: 4
|
126
111
|
summary: Puma integration for Capistrano
|
data/.github/workflows/stale.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
name: Mark stale issues and pull requests
|
2
|
-
|
3
|
-
on:
|
4
|
-
schedule:
|
5
|
-
- cron: "30 1 * * *"
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
stale:
|
9
|
-
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
steps:
|
13
|
-
- uses: actions/stale@v3
|
14
|
-
with:
|
15
|
-
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
16
|
-
stale-issue-message: 'Stale issue message'
|
17
|
-
stale-pr-message: 'Stale pull request message'
|
18
|
-
stale-issue-label: 'no-issue-activity'
|
19
|
-
stale-pr-label: 'no-pr-activity'
|
data/.gitignore
DELETED
data/CONTRIBUTORS.md
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
## Contributors
|
2
|
-
|
3
|
-
- Abdelkader Boudih
|
4
|
-
- André Arko
|
5
|
-
- Ariel Zerahia
|
6
|
-
- Barack Obama
|
7
|
-
- Bart de Water
|
8
|
-
- Benjamin Kim
|
9
|
-
- Bin Huang
|
10
|
-
- Bryan Liles
|
11
|
-
- Claudio Poli
|
12
|
-
- Cyril Rohr
|
13
|
-
- Fritz Lee
|
14
|
-
- Feña Agar
|
15
|
-
- Hnat Kubov
|
16
|
-
- Ivan Schneider
|
17
|
-
- James-Hendrickson
|
18
|
-
- Jens Hausherr
|
19
|
-
- Jeremy Rottman
|
20
|
-
- Jesse Cooke
|
21
|
-
- Johan Lind
|
22
|
-
- Jordan Hollinger
|
23
|
-
- Jun Lin
|
24
|
-
- Kamil Giszczak
|
25
|
-
- Kevin Collignon
|
26
|
-
- Konstantin Papkovskiy
|
27
|
-
- Kyle Decot
|
28
|
-
- Lisa Hagemann
|
29
|
-
- Lonre Wang
|
30
|
-
- Lucas Alves
|
31
|
-
- Marcos Chicote
|
32
|
-
- Mario Celit log
|
33
|
-
- Matias De Santi
|
34
|
-
- Michael C. Beck
|
35
|
-
- Neil Bartley
|
36
|
-
- Philippe Nénert
|
37
|
-
- Ponomarev Nikolay
|
38
|
-
- Rafael Goulart
|
39
|
-
- SHIMADA Koji
|
40
|
-
- Sergey Ponomarev
|
41
|
-
- Shane O'Grady
|
42
|
-
- Simon Males
|
43
|
-
- Steve Madere
|
44
|
-
- Suhail Patel
|
45
|
-
- Suraj Shirvankar
|
46
|
-
- marshall-lee
|
47
|
-
- ruohan chen
|
48
|
-
- ayaya zhao
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/capistrano3-puma.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'capistrano/puma/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'capistrano3-puma'
|
8
|
-
spec.version = Capistrano::PUMAVERSION
|
9
|
-
spec.authors = ['Abdelkader Boudih']
|
10
|
-
spec.email = ['Terminale@gmail.com']
|
11
|
-
spec.description = %q{Puma integration for Capistrano 3}
|
12
|
-
spec.summary = %q{Puma integration for Capistrano}
|
13
|
-
spec.homepage = 'https://github.com/seuros/capistrano-puma'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.required_ruby_version = '>= 1.9.3'
|
17
|
-
|
18
|
-
spec.files = `git ls-files`.split($/)
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_dependency 'capistrano', '~> 3.7'
|
22
|
-
spec.add_dependency 'capistrano-bundler'
|
23
|
-
spec.add_dependency 'puma' , '>= 4.0', '< 6.0'
|
24
|
-
spec.post_install_message = %q{
|
25
|
-
All plugins need to be explicitly installed with install_plugin.
|
26
|
-
Please see README.md
|
27
|
-
}
|
28
|
-
end
|
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Capistrano
|
2
|
-
class Puma::Jungle < Capistrano::Plugin
|
3
|
-
include PumaCommon
|
4
|
-
|
5
|
-
def set_defaults
|
6
|
-
set_if_empty :puma_jungle_conf, '/etc/puma.conf'
|
7
|
-
set_if_empty :puma_run_path, '/usr/local/bin/run-puma'
|
8
|
-
end
|
9
|
-
|
10
|
-
def define_tasks
|
11
|
-
eval_rakefile File.expand_path('../../tasks/jungle.rake', __FILE__)
|
12
|
-
end
|
13
|
-
|
14
|
-
def debian_install(role)
|
15
|
-
template_puma 'puma-deb', "#{fetch(:tmp_dir)}/puma", role
|
16
|
-
end
|
17
|
-
|
18
|
-
def rhel_install(role)
|
19
|
-
template_puma 'puma-rpm', "#{fetch(:tmp_dir)}/puma", role
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,74 +0,0 @@
|
|
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
|
-
|
67
|
-
task :smart_restart do
|
68
|
-
if !fetch(:puma_preload_app) && fetch(:puma_workers, 0).to_i > 1
|
69
|
-
invoke 'puma:phased-restart'
|
70
|
-
else
|
71
|
-
invoke 'puma:restart'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
git_plugin = self
|
2
|
-
|
3
|
-
namespace :puma do
|
4
|
-
namespace :jungle do
|
5
|
-
desc 'Install Puma jungle'
|
6
|
-
task :install do
|
7
|
-
on roles(fetch(:puma_role)) do |role|
|
8
|
-
git_plugin.template_puma 'run-puma', "#{fetch(:tmp_dir)}/run-puma", role
|
9
|
-
execute "chmod +x #{fetch(:tmp_dir)}/run-puma"
|
10
|
-
sudo "mv #{fetch(:tmp_dir)}/run-puma #{fetch(:puma_run_path)}"
|
11
|
-
if test '[ -f /etc/redhat-release ]'
|
12
|
-
#RHEL flavor OS
|
13
|
-
git_plugin.rhel_install(role)
|
14
|
-
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
15
|
-
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
16
|
-
sudo 'chkconfig --add puma'
|
17
|
-
elsif test '[ -f /etc/lsb-release ]'
|
18
|
-
#Debian flavor OS
|
19
|
-
git_plugin.debian_install(role)
|
20
|
-
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
21
|
-
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
22
|
-
sudo 'update-rc.d -f puma defaults'
|
23
|
-
else
|
24
|
-
#Some other OS
|
25
|
-
error 'This task is not supported for your OS'
|
26
|
-
end
|
27
|
-
sudo "touch #{fetch(:puma_jungle_conf)}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'Setup Puma config and install jungle script'
|
32
|
-
task :setup do
|
33
|
-
invoke 'puma:config'
|
34
|
-
invoke 'puma:jungle:install'
|
35
|
-
invoke 'puma:jungle:add'
|
36
|
-
end
|
37
|
-
|
38
|
-
desc 'Add current project to the jungle'
|
39
|
-
task :add do
|
40
|
-
on roles(fetch(:puma_role)) do|role|
|
41
|
-
begin
|
42
|
-
sudo "/etc/init.d/puma add '#{current_path}' #{fetch(:puma_user, role.user)} '#{fetch(:puma_conf)}'"
|
43
|
-
rescue => error
|
44
|
-
warn error
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc 'Remove current project from the jungle'
|
50
|
-
task :remove do
|
51
|
-
on roles(fetch(:puma_role)) do
|
52
|
-
sudo "/etc/init.d/puma remove '#{current_path}'"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
%w[start stop restart status].each do |command|
|
57
|
-
desc "#{command} puma"
|
58
|
-
task command do
|
59
|
-
on roles(fetch(:puma_role)) do
|
60
|
-
sudo "service puma #{command} #{current_path}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
git_plugin = self
|
2
|
-
|
3
|
-
namespace :puma do
|
4
|
-
desc 'Setup Puma config file'
|
5
|
-
task :config do
|
6
|
-
on roles(fetch(:puma_role)) do |role|
|
7
|
-
git_plugin.upload_puma_rb(role)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
task :check do
|
12
|
-
on roles(fetch(:puma_role)) do |role|
|
13
|
-
#Create puma.rb for new deployments
|
14
|
-
unless test "[ -f #{fetch(:puma_conf)} ]"
|
15
|
-
warn 'puma.rb NOT FOUND!'
|
16
|
-
git_plugin.upload_puma_rb(role)
|
17
|
-
info 'puma.rb generated'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
git_plugin = self
|
2
|
-
|
3
|
-
namespace :puma do
|
4
|
-
namespace :workers do
|
5
|
-
desc 'Add a worker'
|
6
|
-
task :count do
|
7
|
-
on roles(fetch(:puma_role)) do |role|
|
8
|
-
git_plugin.puma_switch_user(role) do
|
9
|
-
#TODO
|
10
|
-
# cleanup
|
11
|
-
# add host name/ip
|
12
|
-
puma_pid = capture("cat #{fetch(:puma_pid)}")
|
13
|
-
workers_count = capture("ps ax | grep -c 'puma: cluster worker [0-9]: #{puma_pid}'").to_i
|
14
|
-
log "Workers count : #{workers_count}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# TODO
|
20
|
-
# Add/remove workers to specific host/s
|
21
|
-
# Define # of workers to add/remove
|
22
|
-
# Refactor
|
23
|
-
desc 'Worker++'
|
24
|
-
task :more do
|
25
|
-
on roles(fetch(:puma_role)) do |role|
|
26
|
-
git_plugin.puma_switch_user(role) do
|
27
|
-
puma_pid = capture("cat #{fetch(:puma_pid)}")
|
28
|
-
execute(:kill, "-TTIN #{puma_pid}")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'Worker--'
|
34
|
-
task :less do
|
35
|
-
on roles(fetch(:puma_role)) do |role|
|
36
|
-
git_plugin.puma_switch_user(role) do
|
37
|
-
puma_pid = capture("cat #{fetch(:puma_pid)}")
|
38
|
-
execute(:kill, "-TTOU #{puma_pid}")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
#!/usr/bin/env puma
|
2
|
-
|
3
|
-
directory '<%= current_path %>'
|
4
|
-
rackup "<%=fetch(:puma_rackup)%>"
|
5
|
-
environment '<%= fetch(:puma_env) %>'
|
6
|
-
<% if fetch(:puma_tag) %>
|
7
|
-
tag '<%= fetch(:puma_tag)%>'
|
8
|
-
<% end %>
|
9
|
-
pidfile "<%=fetch(:puma_pid)%>"
|
10
|
-
state_path "<%=fetch(:puma_state)%>"
|
11
|
-
stdout_redirect '<%=fetch(:puma_access_log)%>', '<%=fetch(:puma_error_log)%>', true
|
12
|
-
|
13
|
-
|
14
|
-
threads <%=fetch(:puma_threads).join(',')%>
|
15
|
-
|
16
|
-
<%= puma_plugins %>
|
17
|
-
|
18
|
-
<%= puma_bind %>
|
19
|
-
<% if fetch(:puma_control_app) %>
|
20
|
-
activate_control_app "<%= fetch(:puma_default_control_app) %>"
|
21
|
-
<% end %>
|
22
|
-
workers <%= puma_workers %>
|
23
|
-
<% if fetch(:puma_worker_timeout) %>
|
24
|
-
worker_timeout <%= fetch(:puma_worker_timeout).to_i %>
|
25
|
-
<% end %>
|
26
|
-
|
27
|
-
<% if puma_daemonize? %>
|
28
|
-
daemonize
|
29
|
-
<% end %>
|
30
|
-
|
31
|
-
restart_command '<%= fetch(:puma_restart_command) %>'
|
32
|
-
|
33
|
-
<% if puma_preload_app? %>
|
34
|
-
preload_app!
|
35
|
-
<% else %>
|
36
|
-
prune_bundler
|
37
|
-
<% end %>
|
38
|
-
|
39
|
-
on_restart do
|
40
|
-
puts 'Refreshing Gemfile'
|
41
|
-
ENV["BUNDLE_GEMFILE"] = "<%= fetch(:bundle_gemfile, "#{current_path}/Gemfile") %>"
|
42
|
-
end
|
43
|
-
|
44
|
-
<% if puma_preload_app? and fetch(:puma_init_active_record) %>
|
45
|
-
before_fork do
|
46
|
-
ActiveRecord::Base.connection_pool.disconnect!
|
47
|
-
end
|
48
|
-
|
49
|
-
on_worker_boot do
|
50
|
-
ActiveSupport.on_load(:active_record) do
|
51
|
-
ActiveRecord::Base.establish_connection
|
52
|
-
end
|
53
|
-
end
|
54
|
-
<% end %>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# source ENV variables manually
|
4
|
-
. /etc/environment
|
5
|
-
# on system boot, and root have no rbenv installed,
|
6
|
-
# after start-stop-daemon switched to current user, we have to init rbenv
|
7
|
-
if [ -d "$HOME/.rbenv/bin" ]; then
|
8
|
-
PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
9
|
-
eval "$(rbenv init -)"
|
10
|
-
elif [ -d "/usr/local/rbenv/bin" ]; then
|
11
|
-
PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
|
12
|
-
eval "$(rbenv init -)"
|
13
|
-
elif [ -f /usr/local/rvm/scripts/rvm ]; then
|
14
|
-
source /etc/profile.d/rvm.sh
|
15
|
-
elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
|
16
|
-
source "$HOME/.rvm/scripts/rvm"
|
17
|
-
fi
|
18
|
-
|
19
|
-
app=$1; config=$2; log=$3;
|
20
|
-
cd $app && exec bundle exec puma -C $config 2>&1 >> $log
|