capistrano3-puma 5.2.0 → 6.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +1 -1
- data/README.md +10 -145
- data/lib/capistrano/puma/systemd.rb +11 -6
- data/lib/capistrano/puma.rb +16 -58
- data/lib/capistrano/tasks/systemd.rake +64 -61
- data/lib/capistrano/templates/puma.service.erb +26 -14
- data/lib/generators/capistrano/nginx_puma/config_generator.rb +0 -1
- metadata +12 -33
- 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/monit.rb +0 -34
- data/lib/capistrano/puma/version.rb +0 -5
- 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/monit.rake +0 -61
- data/lib/capistrano/tasks/puma.rake +0 -21
- data/lib/capistrano/tasks/workers.rake +0 -43
- data/lib/capistrano/templates/puma-deb.erb +0 -421
- data/lib/capistrano/templates/puma-rpm.erb +0 -328
- data/lib/capistrano/templates/puma.rb.erb +0 -54
- data/lib/capistrano/templates/puma_monit.conf.erb +0 -7
- data/lib/capistrano/templates/run-puma.erb +0 -20
@@ -1,328 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# puma - this script starts and stops the puma daemon
|
4
|
-
#
|
5
|
-
# chkconfig: - 85 15
|
6
|
-
# description: Description \
|
7
|
-
# goes here...
|
8
|
-
# processname: puma
|
9
|
-
# config: /etc/puma.conf
|
10
|
-
# pidfile: /home/stanislaw/apps/micro-apps/puma/puma.pid
|
11
|
-
# Author: Darío Javier Cravero <'dario@exordo.com'>
|
12
|
-
#
|
13
|
-
# Do NOT "set -e"
|
14
|
-
# Original script https://github.com/puma/puma/blob/master/tools/jungle/puma
|
15
|
-
# It was modified here by Stanislaw Pankevich <'s.pankevich@gmail.com'>
|
16
|
-
# to run on CentOS 5.5 boxes.
|
17
|
-
# Script works perfectly on CentOS 5: script uses its native daemon().
|
18
|
-
# Puma is being stopped/restarted by sending signals, control app is not used.
|
19
|
-
# Source function library.
|
20
|
-
. /etc/rc.d/init.d/functions
|
21
|
-
|
22
|
-
# Source networking configuration.
|
23
|
-
. /etc/sysconfig/network
|
24
|
-
# Check that networking is up.
|
25
|
-
[ "$NETWORKING" = "no" ] && exit 0
|
26
|
-
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
27
|
-
PATH=/usr/local/bin:/usr/local/sbin/:/sbin:/usr/sbin:/bin:/usr/bin
|
28
|
-
DESC="Puma rack web server"
|
29
|
-
NAME=puma
|
30
|
-
DAEMON=$NAME
|
31
|
-
SCRIPTNAME=/etc/init.d/$NAME
|
32
|
-
CONFIG=<%=fetch(:puma_jungle_conf)%>
|
33
|
-
JUNGLE=`cat $CONFIG`
|
34
|
-
RUNPUMA=<%=fetch(:puma_run_path)%>
|
35
|
-
# Skipping the following non-CentOS string
|
36
|
-
# Load the VERBOSE setting and other rcS variables
|
37
|
-
# . /lib/init/vars.sh
|
38
|
-
# CentOS does not have these functions natively
|
39
|
-
log_daemon_msg() { echo "$@"; }
|
40
|
-
log_end_msg() { [ $1 -eq 0 ] && RES=OK; logger ${RES:=FAIL}; }
|
41
|
-
# Define LSB log_* functions.
|
42
|
-
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
43
|
-
. /lib/lsb/init-functions
|
44
|
-
|
45
|
-
#
|
46
|
-
# Function that starts the jungle
|
47
|
-
#
|
48
|
-
do_start() {
|
49
|
-
log_daemon_msg "=> Running the jungle..."
|
50
|
-
for i in $JUNGLE; do
|
51
|
-
dir=`echo $i | cut -d , -f 1`
|
52
|
-
user=`echo $i | cut -d , -f 2`
|
53
|
-
config_file=`echo $i | cut -d , -f 3`
|
54
|
-
if [ "$config_file" = "" ]; then
|
55
|
-
config_file="$dir/config/puma.rb"
|
56
|
-
fi
|
57
|
-
log_file=`echo $i | cut -d , -f 4`
|
58
|
-
if [ "$log_file" = "" ]; then
|
59
|
-
log_file="$dir/log/puma.log"
|
60
|
-
fi
|
61
|
-
do_start_one $dir $user $config_file $log_file
|
62
|
-
done
|
63
|
-
}
|
64
|
-
do_start_one() {
|
65
|
-
PIDFILE=$1/tmp/pids/puma.pid
|
66
|
-
if [ -e $PIDFILE ]; then
|
67
|
-
PID=`cat $PIDFILE`
|
68
|
-
# If the puma isn't running, run it, otherwise restart it.
|
69
|
-
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
70
|
-
do_start_one_do $1 $2
|
71
|
-
else
|
72
|
-
do_restart_one $1
|
73
|
-
fi
|
74
|
-
else
|
75
|
-
do_start_one_do $1 $2 $3 $4
|
76
|
-
fi
|
77
|
-
}
|
78
|
-
do_start_one_do() {
|
79
|
-
log_daemon_msg "--> Woke up puma $1"
|
80
|
-
daemon --user $2 $RUNPUMA $1
|
81
|
-
}
|
82
|
-
#
|
83
|
-
# Function that stops the jungle
|
84
|
-
#
|
85
|
-
do_stop() {
|
86
|
-
log_daemon_msg "=> Putting all the beasts to bed..."
|
87
|
-
for i in $JUNGLE; do
|
88
|
-
dir=`echo $i | cut -d , -f 1`
|
89
|
-
do_stop_one $dir
|
90
|
-
done
|
91
|
-
}
|
92
|
-
#
|
93
|
-
# Function that stops the daemon/service
|
94
|
-
#
|
95
|
-
do_stop_one() {
|
96
|
-
log_daemon_msg "--> Stopping $1"
|
97
|
-
PIDFILE=$1/tmp/pids/puma.pid
|
98
|
-
STATEFILE=$1/tmp/pids/puma.state
|
99
|
-
echo $PIDFILE
|
100
|
-
if [ -e $PIDFILE ]; then
|
101
|
-
PID=`cat $PIDFILE`
|
102
|
-
echo "Pid:"
|
103
|
-
echo $PID
|
104
|
-
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
105
|
-
log_daemon_msg "---> Puma $1 isn't running."
|
106
|
-
else
|
107
|
-
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
108
|
-
pumactl --state $STATEFILE stop
|
109
|
-
rm -f $PIDFILE $STATEFILE
|
110
|
-
fi
|
111
|
-
else
|
112
|
-
log_daemon_msg "---> No puma here..."
|
113
|
-
fi
|
114
|
-
return 0
|
115
|
-
}
|
116
|
-
#
|
117
|
-
# Function that restarts the jungle
|
118
|
-
#
|
119
|
-
do_restart() {
|
120
|
-
for i in $JUNGLE; do
|
121
|
-
dir=`echo $i | cut -d , -f 1`
|
122
|
-
do_restart_one $dir
|
123
|
-
done
|
124
|
-
}
|
125
|
-
#
|
126
|
-
# Function that sends a SIGUSR2 to the daemon/service
|
127
|
-
#
|
128
|
-
do_restart_one() {
|
129
|
-
PIDFILE=$1/tmp/pids/puma.pid
|
130
|
-
i=`grep $1 $CONFIG`
|
131
|
-
dir=`echo $i | cut -d , -f 1`
|
132
|
-
if [ -e $PIDFILE ]; then
|
133
|
-
log_daemon_msg "--> About to restart puma $1"
|
134
|
-
pumactl --state $dir/tmp/pids/puma.state restart
|
135
|
-
|
136
|
-
else
|
137
|
-
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
138
|
-
user=`echo $i | cut -d , -f 2`
|
139
|
-
config_file=`echo $i | cut -d , -f 3`
|
140
|
-
if [ "$config_file" = "" ]; then
|
141
|
-
config_file="$dir/config/puma.rb"
|
142
|
-
fi
|
143
|
-
log_file=`echo $i | cut -d , -f 4`
|
144
|
-
if [ "$log_file" = "" ]; then
|
145
|
-
log_file="$dir/log/puma.log"
|
146
|
-
fi
|
147
|
-
do_start_one $dir $user $config_file $log_file
|
148
|
-
fi
|
149
|
-
return 0
|
150
|
-
}
|
151
|
-
#
|
152
|
-
# Function that statuss then jungle
|
153
|
-
#
|
154
|
-
do_status() {
|
155
|
-
for i in $JUNGLE; do
|
156
|
-
dir=`echo $i | cut -d , -f 1`
|
157
|
-
do_status_one $dir
|
158
|
-
done
|
159
|
-
}
|
160
|
-
#
|
161
|
-
# Function that sends a SIGUSR2 to the daemon/service
|
162
|
-
#
|
163
|
-
do_status_one() {
|
164
|
-
PIDFILE=$1/tmp/pids/puma.pid
|
165
|
-
i=`grep $1 $CONFIG`
|
166
|
-
dir=`echo $i | cut -d , -f 1`
|
167
|
-
if [ -e $PIDFILE ]; then
|
168
|
-
log_daemon_msg "--> About to status puma $1"
|
169
|
-
pumactl --state $dir/tmp/pids/puma.state stats
|
170
|
-
|
171
|
-
else
|
172
|
-
log_daemon_msg "--> $1 isn't there :(..."
|
173
|
-
fi
|
174
|
-
return 0
|
175
|
-
}
|
176
|
-
do_add() {
|
177
|
-
str=""
|
178
|
-
# App's directory
|
179
|
-
if [ -d "$1" ]; then
|
180
|
-
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
181
|
-
str=$1
|
182
|
-
else
|
183
|
-
echo "The app is already being managed. Remove it if you want to update its config."
|
184
|
-
exit 1
|
185
|
-
fi
|
186
|
-
else
|
187
|
-
echo "The directory $1 doesn't exist."
|
188
|
-
exit 1
|
189
|
-
fi
|
190
|
-
# User to run it as
|
191
|
-
if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then
|
192
|
-
echo "The user $2 doesn't exist."
|
193
|
-
exit 1
|
194
|
-
else
|
195
|
-
str="$str,$2"
|
196
|
-
fi
|
197
|
-
# Config file
|
198
|
-
if [ "$3" != "" ]; then
|
199
|
-
if [ -e $3 ]; then
|
200
|
-
str="$str,$3"
|
201
|
-
else
|
202
|
-
echo "The config file $3 doesn't exist."
|
203
|
-
exit 1
|
204
|
-
fi
|
205
|
-
fi
|
206
|
-
# Log file
|
207
|
-
if [ "$4" != "" ]; then
|
208
|
-
str="$str,$4"
|
209
|
-
fi
|
210
|
-
# Add it to the jungle
|
211
|
-
echo $str >> $CONFIG
|
212
|
-
log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
|
213
|
-
}
|
214
|
-
do_remove() {
|
215
|
-
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
216
|
-
echo "There's no app $1 to remove."
|
217
|
-
else
|
218
|
-
# Stop it first.
|
219
|
-
do_stop_one $1
|
220
|
-
# Remove it from the config.
|
221
|
-
sed -i "\\:^$1:d" $CONFIG
|
222
|
-
log_daemon_msg "Removed a Puma from the jungle: $1."
|
223
|
-
fi
|
224
|
-
}
|
225
|
-
case "$1" in
|
226
|
-
start)
|
227
|
-
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
228
|
-
if [ "$#" -eq 1 ]; then
|
229
|
-
do_start
|
230
|
-
else
|
231
|
-
i=`grep $2 $CONFIG`
|
232
|
-
dir=`echo $i | cut -d , -f 1`
|
233
|
-
user=`echo $i | cut -d , -f 2`
|
234
|
-
config_file=`echo $i | cut -d , -f 3`
|
235
|
-
if [ "$config_file" = "" ]; then
|
236
|
-
config_file="$dir/config/puma.rb"
|
237
|
-
fi
|
238
|
-
log_file=`echo $i | cut -d , -f 4`
|
239
|
-
if [ "$log_file" = "" ]; then
|
240
|
-
log_file="$dir/log/puma.log"
|
241
|
-
fi
|
242
|
-
do_start_one $dir $user $config_file $log_file
|
243
|
-
fi
|
244
|
-
case "$?" in
|
245
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
246
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
247
|
-
esac
|
248
|
-
;;
|
249
|
-
stop)
|
250
|
-
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
251
|
-
if [ "$#" -eq 1 ]; then
|
252
|
-
do_stop
|
253
|
-
else
|
254
|
-
i=`grep $2 $CONFIG`
|
255
|
-
dir=`echo $i | cut -d , -f 1`
|
256
|
-
do_stop_one $dir
|
257
|
-
fi
|
258
|
-
case "$?" in
|
259
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
260
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
261
|
-
esac
|
262
|
-
;;
|
263
|
-
status)
|
264
|
-
# TODO Implement.
|
265
|
-
log_daemon_msg "Status $DESC" "$NAME"
|
266
|
-
if [ "$#" -eq 1 ]; then
|
267
|
-
do_status
|
268
|
-
else
|
269
|
-
i=`grep $2 $CONFIG`
|
270
|
-
dir=`echo $i | cut -d , -f 1`
|
271
|
-
do_status_one $dir
|
272
|
-
fi
|
273
|
-
case "$?" in
|
274
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
275
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
276
|
-
esac
|
277
|
-
;;
|
278
|
-
restart)
|
279
|
-
log_daemon_msg "Restarting $DESC" "$NAME"
|
280
|
-
if [ "$#" -eq 1 ]; then
|
281
|
-
do_restart
|
282
|
-
else
|
283
|
-
i=`grep $2 $CONFIG`
|
284
|
-
dir=`echo $i | cut -d , -f 1`
|
285
|
-
do_restart_one $dir
|
286
|
-
fi
|
287
|
-
case "$?" in
|
288
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
289
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
290
|
-
esac
|
291
|
-
;;
|
292
|
-
add)
|
293
|
-
if [ "$#" -lt 3 ]; then
|
294
|
-
echo "Please, specifiy the app's directory and the user that will run it at least."
|
295
|
-
echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
296
|
-
echo " config and log are optionals."
|
297
|
-
exit 1
|
298
|
-
else
|
299
|
-
do_add $2 $3 $4 $5
|
300
|
-
fi
|
301
|
-
case "$?" in
|
302
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
303
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
304
|
-
esac
|
305
|
-
;;
|
306
|
-
remove)
|
307
|
-
if [ "$#" -lt 2 ]; then
|
308
|
-
echo "Please, specifiy the app's directory to remove."
|
309
|
-
exit 1
|
310
|
-
else
|
311
|
-
do_remove $2
|
312
|
-
fi
|
313
|
-
case "$?" in
|
314
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
315
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
316
|
-
esac
|
317
|
-
;;
|
318
|
-
*)
|
319
|
-
echo "Usage:" >&2
|
320
|
-
echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart}" >&2
|
321
|
-
echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
322
|
-
echo " config and log are optionals."
|
323
|
-
echo " Remove a Puma: $SCRIPTNAME remove /path/to/app"
|
324
|
-
echo " On a Puma: $SCRIPTNAME {start|stop|status|restart} PUMA-NAME" >&2
|
325
|
-
exit 3
|
326
|
-
;;
|
327
|
-
esac
|
328
|
-
:
|
@@ -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,7 +0,0 @@
|
|
1
|
-
# Monit configuration for Puma
|
2
|
-
# Service name: <%= puma_monit_service_name %>
|
3
|
-
#
|
4
|
-
check process <%= puma_monit_service_name %>
|
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] %> -C <%= fetch(:puma_conf) %> --daemon'"
|
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'"
|
@@ -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
|