capistrano3-puma 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/capistrano3-puma.gemspec +1 -1
- data/lib/capistrano/puma.rb +2 -2
- data/lib/capistrano/puma/jungle.rb +0 -6
- data/lib/capistrano/puma/monit.rb +6 -3
- data/lib/capistrano/puma/version.rb +1 -1
- data/lib/capistrano/tasks/jungle.rake +11 -1
- data/lib/capistrano/tasks/monit.rake +9 -7
- data/lib/capistrano/templates/nginx_conf.erb +14 -2
- data/lib/capistrano/templates/puma-deb.erb +167 -82
- data/lib/capistrano/templates/run-puma.erb +17 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056f0e760a8050adbfa58de07ea92a2cd19155f6
|
4
|
+
data.tar.gz: 3606335e1e591fa8ec64799560f3305537232662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33112a1a74246ab3b71228d1b0a29cf82c8a04b18408dda5607505ffb9e65519e5cb7d07d5239e75a28b73d99e7f05462d83e3a1421187316d76aa92d41247e3
|
7
|
+
data.tar.gz: 45cf98d18423e1bf5da1a038051ceadfc2301b008120d1106ee749536f999bbd269f3bde6978c3c13723d4faa475d0c11c119971e52b60ca09c0dbc705049462
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ To list available tasks use `cap -T`
|
|
42
42
|
|
43
43
|
To upload puma config use:
|
44
44
|
```ruby
|
45
|
-
cap puma:config
|
45
|
+
cap production puma:config
|
46
46
|
```
|
47
47
|
By default the file located in `shared/puma.config`
|
48
48
|
|
@@ -55,7 +55,7 @@ Ensure that `tmp/pids` and ` tmp/sockets log` are shared (via `linked_dirs`):
|
|
55
55
|
|
56
56
|
To upload a nginx site config (eg. /etc/nginx/sites-enabled/) use:
|
57
57
|
```ruby
|
58
|
-
cap puma:nginx_config
|
58
|
+
cap production puma:nginx_config
|
59
59
|
```
|
60
60
|
|
61
61
|
To customize these two templates locally before uploading use:
|
@@ -124,9 +124,19 @@ Configurable options, shown here with defaults: Please note the configuration op
|
|
124
124
|
set :puma_worker_timeout, nil
|
125
125
|
set :puma_init_active_record, false
|
126
126
|
set :puma_preload_app, false
|
127
|
-
set :puma_daemonize,
|
127
|
+
set :puma_daemonize, false
|
128
128
|
set :puma_plugins, [] #accept array of plugins
|
129
129
|
set :puma_tag, fetch(:application)
|
130
|
+
|
131
|
+
set :nginx_config_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
132
|
+
set :nginx_flags, 'fail_timeout=0'
|
133
|
+
set :nginx_http_flags, fetch(:nginx_flags)
|
134
|
+
set :nginx_server_name, "localhost #{fetch(:application)}.local"
|
135
|
+
set :nginx_sites_available_path, '/etc/nginx/sites-available'
|
136
|
+
set :nginx_sites_enabled_path, '/etc/nginx/sites-enabled'
|
137
|
+
set :nginx_socket_flags, fetch(:nginx_flags)
|
138
|
+
set :nginx_ssl_certificate, "/etc/ssl/certs/{fetch(:nginx_config_name)}.crt"
|
139
|
+
set :nginx_ssl_certificate_key, "/etc/ssl/private/{fetch(:nginx_config_name)}.key"
|
130
140
|
set :nginx_use_ssl, false
|
131
141
|
```
|
132
142
|
|
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}
|
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
|
@@ -118,4 +118,4 @@ end
|
|
118
118
|
require 'capistrano/puma/workers'
|
119
119
|
require 'capistrano/puma/monit'
|
120
120
|
require 'capistrano/puma/jungle'
|
121
|
-
require 'capistrano/puma/nginx'
|
121
|
+
require 'capistrano/puma/nginx'
|
@@ -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,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)}"
|
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
|
@@ -14,7 +14,7 @@ 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
|
|
@@ -22,8 +22,16 @@ server {
|
|
22
22
|
<% if fetch(:nginx_use_ssl) -%>
|
23
23
|
listen 443;
|
24
24
|
ssl on;
|
25
|
+
<% if fetch(:nginx_ssl_certificate) -%>
|
26
|
+
ssl_certificate <%= fetch(:nginx_ssl_certificate) %>;
|
27
|
+
<% else -%>
|
25
28
|
ssl_certificate /etc/ssl/certs/<%= fetch(:nginx_config_name) %>.crt;
|
29
|
+
<% end -%>
|
30
|
+
<% if fetch(:nginx_ssl_certificate_key) -%>
|
31
|
+
ssl_certificate_key <%= fetch(:nginx_ssl_certificate_key) %>;
|
32
|
+
<% else -%>
|
26
33
|
ssl_certificate_key /etc/ssl/private/<%= fetch(:nginx_config_name) %>.key;
|
34
|
+
<% end -%>
|
27
35
|
<% else -%>
|
28
36
|
listen 80;
|
29
37
|
<% end -%>
|
@@ -39,10 +47,14 @@ server {
|
|
39
47
|
|
40
48
|
location @puma_<%= fetch(:nginx_config_name) %> {
|
41
49
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
42
|
-
proxy_set_header Host $
|
50
|
+
proxy_set_header Host $host;
|
43
51
|
proxy_redirect off;
|
52
|
+
proxy_set_header Upgrade $http_upgrade;
|
53
|
+
proxy_set_header Connection "Upgrade";
|
44
54
|
<% if fetch(:nginx_use_ssl) -%>
|
45
55
|
proxy_set_header X-Forwarded-Proto https;
|
56
|
+
<% else -%>
|
57
|
+
proxy_set_header X-Forwarded-Proto http;
|
46
58
|
<% end -%>
|
47
59
|
proxy_pass http://puma_<%= fetch(:nginx_config_name) %>;
|
48
60
|
# 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
|
-
|
@@ -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: 3.1.
|
4
|
+
version: 3.1.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: 2017-
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|