capistrano3-puma 3.1.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -8
- data/CONTRIBUTORS.md +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +48 -5
- data/capistrano3-puma.gemspec +2 -2
- data/lib/capistrano/puma.rb +5 -3
- data/lib/capistrano/puma/daemon.rb +13 -0
- data/lib/capistrano/puma/jungle.rb +0 -6
- data/lib/capistrano/puma/monit.rb +6 -3
- data/lib/capistrano/puma/nginx.rb +2 -0
- data/lib/capistrano/puma/systemd.rb +19 -0
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/daemon.rake +74 -0
- data/lib/capistrano/tasks/jungle.rake +11 -1
- data/lib/capistrano/tasks/monit.rake +9 -7
- data/lib/capistrano/tasks/puma.rake +0 -79
- data/lib/capistrano/tasks/systemd.rake +59 -0
- data/lib/capistrano/templates/nginx_conf.erb +24 -4
- data/lib/capistrano/templates/puma-deb.erb +167 -82
- data/lib/capistrano/templates/puma.rb.erb +2 -0
- data/lib/capistrano/templates/puma.service.erb +18 -0
- data/lib/capistrano/templates/run-puma.erb +17 -6
- metadata +20 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db942a399af982332ceec90035d18c0e46b1f346ba41e4832058fe7e8813982a
|
4
|
+
data.tar.gz: 4beefbf1ec135ea27c80b7dad93fa373d9b4f9d888c8e215573c804e24e09f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdee4e5dfeeeea003da8af2eaffc49ba1bb394162535646fa78179a4958bf4bd0cdcbc1e42f88e7ab6ce841790266625c1ceebbfe5a67eecaa0e1a660cc77e64
|
7
|
+
data.tar.gz: 9eb231db71755a26bd740ec1ae2ad3f86675906f93777683c15d59dbb2698f5769391ebf8b1e2ef86c87f3c7aba9ac23ff159d153be8f88759954daf48dd05f1
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
## Changelog
|
2
|
-
-
|
2
|
+
- 5.0.0:
|
3
|
+
- Support puma 5.0
|
4
|
+
- Support SystemD service manager
|
5
|
+
- 4.0.0:
|
6
|
+
- Support puma 4.x
|
7
|
+
- 3.1.0:
|
3
8
|
- Don't load puma hooks by default.
|
4
9
|
- 3.0.0:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
- Require capistrano 3.7+
|
11
|
+
- Implement the plugin system
|
12
|
+
- don't fail if puma was already running
|
13
|
+
- Added :puma_daemonize option (default is false)
|
9
14
|
|
10
15
|
- 2.0.0:
|
11
|
-
|
12
|
-
|
13
|
-
|
16
|
+
- Require puma 3.4+
|
17
|
+
- Require Capistrano 3.5+
|
18
|
+
- Require capistrano-bundler
|
14
19
|
|
15
20
|
- 1.2.0: add support for puma user for puma user @mcb & @seuros
|
16
21
|
- 1.1.0: Set :puma_preload_app to false; Reload Monit after uploading any monit configuration; Always refresh Gemfile @rafaelgoulart @suhailpatel @sime
|
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
|
@@ -36,15 +44,24 @@ To prevent loading the hooks of the plugin, add false to the load_hooks param.
|
|
36
44
|
install_plugin Capistrano::Puma::Monit, load_hooks: false # Monit tasks without hooks
|
37
45
|
```
|
38
46
|
|
47
|
+
To make it work with rvm, rbenv and chruby, install the plugin after corresponding library inclusion.
|
48
|
+
```ruby
|
49
|
+
# Capfile
|
50
|
+
|
51
|
+
require 'capistrano/rbenv'
|
52
|
+
require 'capistrano/puma'
|
53
|
+
install_plugin Capistrano::Puma
|
54
|
+
```
|
55
|
+
|
39
56
|
### Config
|
40
57
|
|
41
58
|
To list available tasks use `cap -T`
|
42
59
|
|
43
60
|
To upload puma config use:
|
44
61
|
```ruby
|
45
|
-
cap puma:config
|
62
|
+
cap production puma:config
|
46
63
|
```
|
47
|
-
By default the file located in `shared/puma.
|
64
|
+
By default the file located in `shared/puma.rb`
|
48
65
|
|
49
66
|
|
50
67
|
Ensure that `tmp/pids` and ` tmp/sockets log` are shared (via `linked_dirs`):
|
@@ -55,7 +72,7 @@ Ensure that `tmp/pids` and ` tmp/sockets log` are shared (via `linked_dirs`):
|
|
55
72
|
|
56
73
|
To upload a nginx site config (eg. /etc/nginx/sites-enabled/) use:
|
57
74
|
```ruby
|
58
|
-
cap puma:nginx_config
|
75
|
+
cap production puma:nginx_config
|
59
76
|
```
|
60
77
|
|
61
78
|
To customize these two templates locally before uploading use:
|
@@ -86,13 +103,26 @@ For Jungle tasks (beta), these options exist:
|
|
86
103
|
set :puma_run_path, '/usr/local/bin/run-puma'
|
87
104
|
```
|
88
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
|
+
|
89
119
|
### Multi bind
|
90
120
|
|
91
121
|
Multi-bind can be set with an array in the puma_bind variable
|
92
122
|
```ruby
|
93
123
|
set :puma_bind, %w(tcp://0.0.0.0:9292 unix:///tmp/puma.sock)
|
94
124
|
```
|
95
|
-
* Listening on tcp://0.0.0.0:
|
125
|
+
* Listening on tcp://0.0.0.0:9292
|
96
126
|
* Listening on unix:///tmp/puma.sock
|
97
127
|
|
98
128
|
### Active Record
|
@@ -124,10 +154,23 @@ Configurable options, shown here with defaults: Please note the configuration op
|
|
124
154
|
set :puma_worker_timeout, nil
|
125
155
|
set :puma_init_active_record, false
|
126
156
|
set :puma_preload_app, false
|
127
|
-
set :puma_daemonize,
|
157
|
+
set :puma_daemonize, false
|
128
158
|
set :puma_plugins, [] #accept array of plugins
|
129
159
|
set :puma_tag, fetch(:application)
|
160
|
+
set :puma_restart_command, 'bundle exec puma'
|
161
|
+
|
162
|
+
set :nginx_config_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
163
|
+
set :nginx_flags, 'fail_timeout=0'
|
164
|
+
set :nginx_http_flags, fetch(:nginx_flags)
|
165
|
+
set :nginx_server_name, "localhost #{fetch(:application)}.local"
|
166
|
+
set :nginx_sites_available_path, '/etc/nginx/sites-available'
|
167
|
+
set :nginx_sites_enabled_path, '/etc/nginx/sites-enabled'
|
168
|
+
set :nginx_socket_flags, fetch(:nginx_flags)
|
169
|
+
set :nginx_ssl_certificate, "/etc/ssl/certs/#{fetch(:nginx_config_name)}.crt"
|
170
|
+
set :nginx_ssl_certificate_key, "/etc/ssl/private/#{fetch(:nginx_config_name)}.key"
|
130
171
|
set :nginx_use_ssl, false
|
172
|
+
set :nginx_use_http2, true
|
173
|
+
set :nginx_downstream_uses_ssl, false
|
131
174
|
```
|
132
175
|
|
133
176
|
__Notes:__ If you are setting values for variables that might be used by other plugins, use `append` instead of `set`. For example:
|
data/capistrano3-puma.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'capistrano/puma/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'capistrano3-puma'
|
8
|
-
spec.version = Capistrano::
|
8
|
+
spec.version = Capistrano::PUMAVERSION
|
9
9
|
spec.authors = ['Abdelkader Boudih']
|
10
10
|
spec.email = ['Terminale@gmail.com']
|
11
11
|
spec.description = %q{Puma integration for Capistrano 3}
|
@@ -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
@@ -8,7 +8,7 @@ module Capistrano
|
|
8
8
|
if user == role.user
|
9
9
|
block.call
|
10
10
|
else
|
11
|
-
as user do
|
11
|
+
backend.as user do
|
12
12
|
block.call
|
13
13
|
end
|
14
14
|
end
|
@@ -76,6 +76,7 @@ module Capistrano
|
|
76
76
|
set_if_empty :puma_preload_app, false
|
77
77
|
set_if_empty :puma_daemonize, false
|
78
78
|
set_if_empty :puma_tag, ''
|
79
|
+
set_if_empty :puma_restart_command, 'bundle exec puma'
|
79
80
|
|
80
81
|
# Chruby, Rbenv and RVM integration
|
81
82
|
append :chruby_map_bins, 'puma', 'pumactl'
|
@@ -88,7 +89,6 @@ module Capistrano
|
|
88
89
|
|
89
90
|
def register_hooks
|
90
91
|
after 'deploy:check', 'puma:check'
|
91
|
-
after 'deploy:finished', 'puma:smart_restart'
|
92
92
|
end
|
93
93
|
|
94
94
|
def puma_workers
|
@@ -116,6 +116,8 @@ module Capistrano
|
|
116
116
|
end
|
117
117
|
|
118
118
|
require 'capistrano/puma/workers'
|
119
|
+
require 'capistrano/puma/daemon'
|
120
|
+
require 'capistrano/puma/systemd'
|
119
121
|
require 'capistrano/puma/monit'
|
120
122
|
require 'capistrano/puma/jungle'
|
121
|
-
require 'capistrano/puma/nginx'
|
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
|
@@ -13,16 +13,10 @@ module Capistrano
|
|
13
13
|
|
14
14
|
def debian_install(role)
|
15
15
|
template_puma 'puma-deb', "#{fetch(:tmp_dir)}/puma", role
|
16
|
-
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
17
|
-
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
18
|
-
sudo 'update-rc.d -f puma defaults'
|
19
16
|
end
|
20
17
|
|
21
18
|
def rhel_install(role)
|
22
19
|
template_puma 'puma-rpm', "#{fetch(:tmp_dir)}/puma", role
|
23
|
-
execute "chmod +x #{fetch(:tmp_dir)}/puma"
|
24
|
-
sudo "mv #{fetch(:tmp_dir)}/puma /etc/init.d/puma"
|
25
|
-
sudo 'chkconfig --add puma'
|
26
20
|
end
|
27
21
|
end
|
28
22
|
end
|
@@ -22,10 +22,13 @@ module Capistrano
|
|
22
22
|
|
23
23
|
def sudo_if_needed(command)
|
24
24
|
if fetch(:puma_monit_use_sudo)
|
25
|
-
sudo command
|
25
|
+
backend.sudo command
|
26
26
|
else
|
27
|
-
|
27
|
+
puma_role = fetch(:puma_role)
|
28
|
+
backend.on(puma_role) do
|
29
|
+
backend.execute command
|
30
|
+
end
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
31
|
-
end
|
34
|
+
end
|
@@ -11,6 +11,8 @@ 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
|
15
|
+
set_if_empty :nginx_downstream_uses_ssl, false
|
14
16
|
end
|
15
17
|
|
16
18
|
def define_tasks
|
@@ -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,74 @@
|
|
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
|
@@ -11,9 +11,15 @@ namespace :puma do
|
|
11
11
|
if test '[ -f /etc/redhat-release ]'
|
12
12
|
#RHEL flavor OS
|
13
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'
|
14
17
|
elsif test '[ -f /etc/lsb-release ]'
|
15
18
|
#Debian flavor OS
|
16
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'
|
17
23
|
else
|
18
24
|
#Some other OS
|
19
25
|
error 'This task is not supported for your OS'
|
@@ -32,7 +38,11 @@ namespace :puma do
|
|
32
38
|
desc 'Add current project to the jungle'
|
33
39
|
task :add do
|
34
40
|
on roles(fetch(:puma_role)) do|role|
|
35
|
-
|
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
|
36
46
|
end
|
37
47
|
end
|
38
48
|
|
@@ -8,6 +8,8 @@ namespace :puma do
|
|
8
8
|
git_plugin.template_puma 'puma_monit.conf', "#{fetch(:tmp_dir)}/monit.conf", role
|
9
9
|
git_plugin.sudo_if_needed "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:puma_monit_conf_dir)}"
|
10
10
|
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} reload"
|
11
|
+
# Wait for Monit to be reloaded
|
12
|
+
sleep 1
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -15,10 +17,10 @@ namespace :puma do
|
|
15
17
|
task :monitor do
|
16
18
|
on roles(fetch(:puma_role)) do
|
17
19
|
begin
|
18
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} monitor #{puma_monit_service_name}"
|
20
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} monitor #{git_plugin.puma_monit_service_name}"
|
19
21
|
rescue
|
20
22
|
invoke 'puma:monit:config'
|
21
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} monitor #{puma_monit_service_name}"
|
23
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} monitor #{git_plugin.puma_monit_service_name}"
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -27,7 +29,7 @@ namespace :puma do
|
|
27
29
|
task :unmonitor do
|
28
30
|
on roles(fetch(:puma_role)) do
|
29
31
|
begin
|
30
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} unmonitor #{puma_monit_service_name}"
|
32
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} unmonitor #{git_plugin.puma_monit_service_name}"
|
31
33
|
rescue
|
32
34
|
# no worries here (still no monitoring)
|
33
35
|
end
|
@@ -37,23 +39,23 @@ namespace :puma do
|
|
37
39
|
desc 'Start Puma monit-service'
|
38
40
|
task :start do
|
39
41
|
on roles(fetch(:puma_role)) do
|
40
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} start #{puma_monit_service_name}"
|
42
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} start #{git_plugin.puma_monit_service_name}"
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
desc 'Stop Puma monit-service'
|
45
47
|
task :stop do
|
46
48
|
on roles(fetch(:puma_role)) do
|
47
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} stop #{puma_monit_service_name}"
|
49
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} stop #{git_plugin.puma_monit_service_name}"
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
53
|
desc 'Restart Puma monit-service'
|
52
54
|
task :restart do
|
53
55
|
on roles(fetch(:puma_role)) do
|
54
|
-
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} restart #{puma_monit_service_name}"
|
56
|
+
git_plugin.sudo_if_needed "#{fetch(:puma_monit_bin)} restart #{git_plugin.puma_monit_service_name}"
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
60
|
end
|
59
|
-
end
|
61
|
+
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
|
@@ -14,16 +14,27 @@ end
|
|
14
14
|
server {
|
15
15
|
listen 80;
|
16
16
|
server_name <%= fetch(:nginx_server_name) %>;
|
17
|
-
|
17
|
+
return 301 https://$host$1$request_uri;
|
18
18
|
}
|
19
19
|
<% end -%>
|
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 -%>
|
28
|
+
<% if fetch(:nginx_ssl_certificate) -%>
|
29
|
+
ssl_certificate <%= fetch(:nginx_ssl_certificate) %>;
|
30
|
+
<% else -%>
|
25
31
|
ssl_certificate /etc/ssl/certs/<%= fetch(:nginx_config_name) %>.crt;
|
32
|
+
<% end -%>
|
33
|
+
<% if fetch(:nginx_ssl_certificate_key) -%>
|
34
|
+
ssl_certificate_key <%= fetch(:nginx_ssl_certificate_key) %>;
|
35
|
+
<% else -%>
|
26
36
|
ssl_certificate_key /etc/ssl/private/<%= fetch(:nginx_config_name) %>.key;
|
37
|
+
<% end -%>
|
27
38
|
<% else -%>
|
28
39
|
listen 80;
|
29
40
|
<% end -%>
|
@@ -38,11 +49,20 @@ server {
|
|
38
49
|
error_page 503 @503;
|
39
50
|
|
40
51
|
location @puma_<%= fetch(:nginx_config_name) %> {
|
52
|
+
proxy_http_version 1.1;
|
41
53
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
42
|
-
proxy_set_header Host $
|
54
|
+
proxy_set_header Host $host;
|
43
55
|
proxy_redirect off;
|
56
|
+
proxy_set_header Upgrade $http_upgrade;
|
57
|
+
proxy_set_header Connection "Upgrade";
|
44
58
|
<% if fetch(:nginx_use_ssl) -%>
|
45
59
|
proxy_set_header X-Forwarded-Proto https;
|
60
|
+
<% else -%>
|
61
|
+
<% if fetch(:nginx_downstream_uses_ssl) -%>
|
62
|
+
proxy_set_header X-Forwarded-Proto https;
|
63
|
+
<% else -%>
|
64
|
+
proxy_set_header X-Forwarded-Proto http;
|
65
|
+
<% end -%>
|
46
66
|
<% end -%>
|
47
67
|
proxy_pass http://puma_<%= fetch(:nginx_config_name) %>;
|
48
68
|
# limit_req zone=one;
|
@@ -1,17 +1,16 @@
|
|
1
1
|
#! /bin/sh
|
2
2
|
### BEGIN INIT INFO
|
3
|
-
# Provides:
|
4
|
-
# Required-Start:
|
5
|
-
# Required-Stop:
|
6
|
-
# Default-Start:
|
7
|
-
# Default-Stop:
|
8
|
-
# Short-Description:
|
9
|
-
# Description:
|
10
|
-
# placed in /etc/init.d.
|
3
|
+
# Provides: puma
|
4
|
+
# Required-Start: $remote_fs $syslog
|
5
|
+
# Required-Stop: $remote_fs $syslog
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Puma web server
|
9
|
+
# Description: A ruby web server built for concurrency http://puma.io
|
10
|
+
# initscript to be placed in /etc/init.d.
|
11
11
|
### END INIT INFO
|
12
12
|
|
13
|
-
# Author: Darío Javier Cravero <
|
14
|
-
# Modified by: Abdelkader Boudih <'terminale@gmail.com'>
|
13
|
+
# Author: Darío Javier Cravero <dario@exordo.com>
|
15
14
|
#
|
16
15
|
# Do NOT "set -e"
|
17
16
|
|
@@ -24,6 +23,7 @@ SCRIPTNAME=/etc/init.d/$NAME
|
|
24
23
|
CONFIG=<%=fetch(:puma_jungle_conf)%>
|
25
24
|
JUNGLE=`cat $CONFIG`
|
26
25
|
RUNPUMA=<%=fetch(:puma_run_path)%>
|
26
|
+
USE_LOCAL_BUNDLE=0
|
27
27
|
|
28
28
|
# Load the VERBOSE setting and other rcS variables
|
29
29
|
. /lib/init/vars.sh
|
@@ -33,22 +33,13 @@ RUNPUMA=<%=fetch(:puma_run_path)%>
|
|
33
33
|
. /lib/lsb/init-functions
|
34
34
|
|
35
35
|
#
|
36
|
-
# Function that starts the jungle
|
36
|
+
# Function that starts the jungle
|
37
37
|
#
|
38
38
|
do_start() {
|
39
39
|
log_daemon_msg "=> Running the jungle..."
|
40
40
|
for i in $JUNGLE; do
|
41
41
|
dir=`echo $i | cut -d , -f 1`
|
42
|
-
|
43
|
-
config_file=`echo $i | cut -d , -f 3`
|
44
|
-
if [ "$config_file" = "" ]; then
|
45
|
-
config_file="$dir/config/puma.rb"
|
46
|
-
fi
|
47
|
-
log_file=`echo $i | cut -d , -f 4`
|
48
|
-
if [ "$log_file" = "" ]; then
|
49
|
-
log_file="$dir/log/puma.log"
|
50
|
-
fi
|
51
|
-
do_start_one $dir $user $config_file $log_file
|
42
|
+
do_start_one $dir
|
52
43
|
done
|
53
44
|
}
|
54
45
|
|
@@ -58,21 +49,41 @@ do_start_one() {
|
|
58
49
|
PID=`cat $PIDFILE`
|
59
50
|
# If the puma isn't running, run it, otherwise restart it.
|
60
51
|
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
61
|
-
do_start_one_do $1
|
52
|
+
do_start_one_do $1
|
62
53
|
else
|
63
|
-
do_restart_one $1
|
54
|
+
do_restart_one $1
|
64
55
|
fi
|
65
56
|
else
|
66
|
-
do_start_one_do $1
|
57
|
+
do_start_one_do $1
|
67
58
|
fi
|
68
59
|
}
|
69
60
|
|
70
61
|
do_start_one_do() {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
i=`grep $1 $CONFIG`
|
63
|
+
dir=`echo $i | cut -d , -f 1`
|
64
|
+
user=`echo $i | cut -d , -f 2`
|
65
|
+
config_file=`echo $i | cut -d , -f 3`
|
66
|
+
if [ "$config_file" = "" ]; then
|
67
|
+
config_file="$dir/config/puma.rb"
|
68
|
+
fi
|
69
|
+
log_file=`echo $i | cut -d , -f 4`
|
70
|
+
if [ "$log_file" = "" ]; then
|
71
|
+
log_file="$dir/log/puma.log"
|
72
|
+
fi
|
73
|
+
environment=`echo $i | cut -d , -f 5`
|
74
|
+
|
75
|
+
log_daemon_msg "--> Woke up puma $dir"
|
76
|
+
log_daemon_msg "user $user"
|
77
|
+
log_daemon_msg "log to $log_file"
|
78
|
+
|
79
|
+
if [ ! -z "$environment" ]; then
|
80
|
+
for e in $(echo "$environment" | tr ';' '\n'); do
|
81
|
+
log_daemon_msg "environment $e"
|
82
|
+
v=${e%%\=*} ; eval "$e" ; export $v
|
83
|
+
done
|
84
|
+
fi
|
85
|
+
|
86
|
+
start-stop-daemon --verbose --start --chdir $dir --chuid $user --background --exec $RUNPUMA -- $dir $config_file $log_file
|
76
87
|
}
|
77
88
|
|
78
89
|
#
|
@@ -82,8 +93,7 @@ do_stop() {
|
|
82
93
|
log_daemon_msg "=> Putting all the beasts to bed..."
|
83
94
|
for i in $JUNGLE; do
|
84
95
|
dir=`echo $i | cut -d , -f 1`
|
85
|
-
|
86
|
-
do_stop_one $dir $user
|
96
|
+
do_stop_one $dir
|
87
97
|
done
|
88
98
|
}
|
89
99
|
#
|
@@ -99,7 +109,11 @@ do_stop_one() {
|
|
99
109
|
log_daemon_msg "---> Puma $1 isn't running."
|
100
110
|
else
|
101
111
|
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
102
|
-
|
112
|
+
if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then
|
113
|
+
cd $1 && bundle exec pumactl --state $STATEFILE stop
|
114
|
+
else
|
115
|
+
pumactl --state $STATEFILE stop
|
116
|
+
fi
|
103
117
|
# Many daemons don't delete their pidfiles when they exit.
|
104
118
|
rm -f $PIDFILE $STATEFILE
|
105
119
|
fi
|
@@ -110,13 +124,12 @@ do_stop_one() {
|
|
110
124
|
}
|
111
125
|
|
112
126
|
#
|
113
|
-
# Function that restarts the jungle
|
127
|
+
# Function that restarts the jungle
|
114
128
|
#
|
115
129
|
do_restart() {
|
116
130
|
for i in $JUNGLE; do
|
117
131
|
dir=`echo $i | cut -d , -f 1`
|
118
|
-
|
119
|
-
do_restart_one $dir $user
|
132
|
+
do_restart_one $dir
|
120
133
|
done
|
121
134
|
}
|
122
135
|
|
@@ -125,39 +138,52 @@ do_restart() {
|
|
125
138
|
#
|
126
139
|
do_restart_one() {
|
127
140
|
PIDFILE=$1/tmp/pids/puma.pid
|
128
|
-
i=`grep $1 $CONFIG`
|
129
|
-
dir=`echo $i | cut -d , -f 1`
|
130
141
|
|
131
142
|
if [ -e $PIDFILE ]; then
|
132
143
|
log_daemon_msg "--> About to restart puma $1"
|
133
|
-
|
134
|
-
# kill -s USR2 `cat $PIDFILE`
|
144
|
+
kill -s USR2 `cat $PIDFILE`
|
135
145
|
# TODO Check if process exist
|
136
146
|
else
|
137
147
|
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
138
|
-
|
139
|
-
config_file=`echo $i | cut -d , -f 3`
|
140
|
-
if [ "$config_file" = "" ]; then
|
141
|
-
config_file="$dir/config/puma.rb"
|
142
|
-
do_start_one $dir $user $config_file
|
143
|
-
fi
|
144
|
-
log_file=`echo $i | cut -d , -f 4`
|
145
|
-
if [ "$log_file" = "" ]; then
|
146
|
-
log_file="$dir/log/puma.log"
|
147
|
-
fi
|
148
|
-
do_start_one $dir $user $config_file $log_file
|
148
|
+
do_start_one $1
|
149
149
|
fi
|
150
|
-
|
150
|
+
return 0
|
151
|
+
}
|
152
|
+
|
153
|
+
#
|
154
|
+
# Function that phased restarts the jungle
|
155
|
+
#
|
156
|
+
do_phased_restart() {
|
157
|
+
for i in $JUNGLE; do
|
158
|
+
dir=`echo $i | cut -d , -f 1`
|
159
|
+
do_phased_restart_one $dir
|
160
|
+
done
|
161
|
+
}
|
162
|
+
|
163
|
+
#
|
164
|
+
# Function that sends a SIGUSR1 to the daemon/service
|
165
|
+
#
|
166
|
+
do_phased_restart_one() {
|
167
|
+
PIDFILE=$1/tmp/pids/puma.pid
|
168
|
+
|
169
|
+
if [ -e $PIDFILE ]; then
|
170
|
+
log_daemon_msg "--> About to restart puma $1"
|
171
|
+
kill -s USR1 `cat $PIDFILE`
|
172
|
+
# TODO Check if process exist
|
173
|
+
else
|
174
|
+
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
175
|
+
do_start_one $1
|
176
|
+
fi
|
177
|
+
return 0
|
151
178
|
}
|
152
179
|
|
153
180
|
#
|
154
|
-
# Function that statuss the jungle
|
181
|
+
# Function that statuss the jungle
|
155
182
|
#
|
156
183
|
do_status() {
|
157
184
|
for i in $JUNGLE; do
|
158
185
|
dir=`echo $i | cut -d , -f 1`
|
159
|
-
|
160
|
-
do_status_one $dir $user
|
186
|
+
do_status_one $dir
|
161
187
|
done
|
162
188
|
}
|
163
189
|
|
@@ -168,16 +194,20 @@ do_status_one() {
|
|
168
194
|
PIDFILE=$1/tmp/pids/puma.pid
|
169
195
|
i=`grep $1 $CONFIG`
|
170
196
|
dir=`echo $i | cut -d , -f 1`
|
171
|
-
|
197
|
+
|
172
198
|
if [ -e $PIDFILE ]; then
|
173
199
|
log_daemon_msg "--> About to status puma $1"
|
174
|
-
|
175
|
-
|
176
|
-
|
200
|
+
if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then
|
201
|
+
cd $1 && bundle exec pumactl --state $dir/tmp/pids/puma.state stats
|
202
|
+
else
|
203
|
+
pumactl --state $dir/tmp/pids/puma.state stats
|
204
|
+
fi
|
205
|
+
# kill -s USR2 `cat $PIDFILE`
|
206
|
+
# TODO Check if process exist
|
177
207
|
else
|
178
|
-
log_daemon_msg "--> $1 isn't there :(..."
|
208
|
+
log_daemon_msg "--> $1 isn't there :(..."
|
179
209
|
fi
|
180
|
-
|
210
|
+
return 0
|
181
211
|
}
|
182
212
|
|
183
213
|
do_add() {
|
@@ -188,7 +218,7 @@ do_add() {
|
|
188
218
|
str=$1
|
189
219
|
else
|
190
220
|
echo "The app is already being managed. Remove it if you want to update its config."
|
191
|
-
exit
|
221
|
+
exit 1
|
192
222
|
fi
|
193
223
|
else
|
194
224
|
echo "The directory $1 doesn't exist."
|
@@ -215,7 +245,12 @@ do_add() {
|
|
215
245
|
str="$str,$4"
|
216
246
|
fi
|
217
247
|
|
218
|
-
#
|
248
|
+
# Environment variables
|
249
|
+
if [ "$5" != "" ]; then
|
250
|
+
str="$str,$5"
|
251
|
+
fi
|
252
|
+
|
253
|
+
# Add it to the jungle
|
219
254
|
echo $str >> $CONFIG
|
220
255
|
log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
|
221
256
|
}
|
@@ -232,6 +267,49 @@ do_remove() {
|
|
232
267
|
fi
|
233
268
|
}
|
234
269
|
|
270
|
+
config_bundler() {
|
271
|
+
HOME="$(eval echo ~$(id -un))"
|
272
|
+
|
273
|
+
if [ -d "$1/.rbenv/bin" ]; then
|
274
|
+
PATH="$1/.rbenv/bin:$1/.rbenv/shims:$1"
|
275
|
+
eval "$(rbenv init -)"
|
276
|
+
USE_LOCAL_BUNDLE=1
|
277
|
+
return 0
|
278
|
+
|
279
|
+
elif [ -d "/usr/local/rbenv/bin" ]; then
|
280
|
+
PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
|
281
|
+
eval "$(rbenv init -)"
|
282
|
+
USE_LOCAL_BUNDLE=1
|
283
|
+
return 0
|
284
|
+
|
285
|
+
elif [ -d "$HOME/.rbenv/bin" ]; then
|
286
|
+
PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
287
|
+
eval "$(rbenv init -)"
|
288
|
+
USE_LOCAL_BUNDLE=1
|
289
|
+
return 0
|
290
|
+
|
291
|
+
# TODO: test rvm
|
292
|
+
# elif [ -f /etc/profile.d/rvm.sh ]; then
|
293
|
+
# source /etc/profile.d/rvm.sh
|
294
|
+
# elif [ -f /usr/local/rvm/scripts/rvm ]; then
|
295
|
+
# source /etc/profile.d/rvm.sh
|
296
|
+
# elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
|
297
|
+
# source "$HOME/.rvm/scripts/rvm"
|
298
|
+
# TODO: don't know what to do with chruby
|
299
|
+
# elif [ -f /usr/local/share/chruby/chruby.sh ]; then
|
300
|
+
# source /usr/local/share/chruby/chruby.sh
|
301
|
+
# if [ -f /usr/local/share/chruby/auto.sh ]; then
|
302
|
+
# source /usr/local/share/chruby/auto.sh
|
303
|
+
# fi
|
304
|
+
# if you aren't using auto, set your version here
|
305
|
+
# chruby 2.0.0
|
306
|
+
fi
|
307
|
+
|
308
|
+
return 1
|
309
|
+
}
|
310
|
+
|
311
|
+
config_bundler
|
312
|
+
|
235
313
|
case "$1" in
|
236
314
|
start)
|
237
315
|
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
@@ -240,18 +318,12 @@ case "$1" in
|
|
240
318
|
else
|
241
319
|
i=`grep $2 $CONFIG`
|
242
320
|
dir=`echo $i | cut -d , -f 1`
|
243
|
-
|
244
|
-
config_file=`echo $i | cut -d , -f 3`
|
245
|
-
if [ "$config_file" = "" ]; then
|
246
|
-
config_file="$dir/config/puma.rb"
|
247
|
-
|
248
|
-
do_start_one $dir $user $config_file
|
249
|
-
fi
|
250
|
-
case "$?" in
|
251
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
252
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
253
|
-
esac
|
321
|
+
do_start_one $dir
|
254
322
|
fi
|
323
|
+
case "$?" in
|
324
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
325
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
326
|
+
esac
|
255
327
|
;;
|
256
328
|
stop)
|
257
329
|
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
@@ -296,11 +368,25 @@ case "$1" in
|
|
296
368
|
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
297
369
|
esac
|
298
370
|
;;
|
371
|
+
phased-restart)
|
372
|
+
log_daemon_msg "Restarting (phased) $DESC" "$NAME"
|
373
|
+
if [ "$#" -eq 1 ]; then
|
374
|
+
do_phased_restart
|
375
|
+
else
|
376
|
+
i=`grep $2 $CONFIG`
|
377
|
+
dir=`echo $i | cut -d , -f 1`
|
378
|
+
do_phased_restart_one $dir
|
379
|
+
fi
|
380
|
+
case "$?" in
|
381
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
382
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
383
|
+
esac
|
384
|
+
;;
|
299
385
|
add)
|
300
386
|
if [ "$#" -lt 3 ]; then
|
301
|
-
echo "Please,
|
302
|
-
echo "
|
303
|
-
echo "
|
387
|
+
echo "Please, specify the app's directory and the user that will run it at least."
|
388
|
+
echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
389
|
+
echo " config and log are optionals."
|
304
390
|
exit 1
|
305
391
|
else
|
306
392
|
do_add $2 $3 $4 $5
|
@@ -324,13 +410,12 @@ case "$1" in
|
|
324
410
|
;;
|
325
411
|
*)
|
326
412
|
echo "Usage:" >&2
|
327
|
-
echo "
|
328
|
-
echo "
|
329
|
-
echo "
|
330
|
-
echo "
|
331
|
-
echo "
|
413
|
+
echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart|phased-restart}" >&2
|
414
|
+
echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
415
|
+
echo " config and log are optionals."
|
416
|
+
echo " Remove a Puma: $SCRIPTNAME remove /path/to/app"
|
417
|
+
echo " On a Puma: $SCRIPTNAME {start|stop|status|restart|phased-restart} PUMA-NAME" >&2
|
332
418
|
exit 3
|
333
419
|
;;
|
334
420
|
esac
|
335
421
|
:
|
336
|
-
|
@@ -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
|
@@ -1,9 +1,20 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
app=$1;
|
3
|
-
cd $app || exit 1
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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"
|
9
17
|
fi
|
18
|
+
|
19
|
+
app=$1; config=$2; log=$3;
|
20
|
+
cd $app && exec bundle exec puma -C $config 2>&1 >> $log
|
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.1
|
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-12-02 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
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
- - "<"
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
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
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '4.0'
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
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
|
@@ -107,9 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
118
|
- !ruby/object:Gem::Version
|
108
119
|
version: '0'
|
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: []
|