puma 4.3.8 → 5.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +1543 -521
- data/LICENSE +23 -20
- data/README.md +120 -36
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +63 -26
- data/docs/compile_options.md +21 -0
- data/docs/deployment.md +60 -69
- data/docs/fork_worker.md +33 -0
- data/docs/jungle/README.md +9 -0
- data/{tools → docs}/jungle/rc.d/README.md +1 -1
- data/{tools → docs}/jungle/rc.d/puma +2 -2
- data/docs/kubernetes.md +66 -0
- data/docs/nginx.md +1 -1
- data/docs/plugins.md +15 -15
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +46 -23
- data/docs/signals.md +13 -11
- data/docs/stats.md +142 -0
- data/docs/systemd.md +85 -128
- data/ext/puma_http11/PumaHttp11Service.java +2 -4
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/extconf.rb +51 -9
- data/ext/puma_http11/http11_parser.c +68 -57
- data/ext/puma_http11/http11_parser.h +1 -1
- data/ext/puma_http11/http11_parser.java.rl +1 -1
- data/ext/puma_http11/http11_parser.rl +1 -1
- data/ext/puma_http11/http11_parser_common.rl +1 -1
- data/ext/puma_http11/mini_ssl.c +295 -124
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +5 -3
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +51 -51
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +109 -67
- data/ext/puma_http11/puma_http11.c +32 -51
- data/lib/puma/app/status.rb +50 -36
- data/lib/puma/binder.rb +225 -106
- data/lib/puma/cli.rb +24 -18
- data/lib/puma/client.rb +197 -92
- data/lib/puma/cluster/worker.rb +173 -0
- data/lib/puma/cluster/worker_handle.rb +94 -0
- data/lib/puma/cluster.rb +212 -220
- data/lib/puma/commonlogger.rb +2 -2
- data/lib/puma/configuration.rb +58 -49
- data/lib/puma/const.rb +26 -9
- data/lib/puma/control_cli.rb +99 -76
- data/lib/puma/detect.rb +29 -2
- data/lib/puma/dsl.rb +368 -96
- data/lib/puma/error_logger.rb +104 -0
- data/lib/puma/events.rb +55 -34
- data/lib/puma/io_buffer.rb +9 -2
- data/lib/puma/jruby_restart.rb +0 -58
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher.rb +128 -46
- data/lib/puma/minissl/context_builder.rb +14 -9
- data/lib/puma/minissl.rb +137 -50
- data/lib/puma/null_io.rb +18 -1
- data/lib/puma/plugin.rb +3 -12
- data/lib/puma/queue_close.rb +26 -0
- data/lib/puma/rack/builder.rb +1 -5
- data/lib/puma/reactor.rb +85 -369
- data/lib/puma/request.rb +489 -0
- data/lib/puma/runner.rb +46 -61
- data/lib/puma/server.rb +292 -751
- data/lib/puma/single.rb +9 -65
- data/lib/puma/state_file.rb +48 -8
- data/lib/puma/systemd.rb +46 -0
- data/lib/puma/thread_pool.rb +125 -57
- data/lib/puma/util.rb +32 -4
- data/lib/puma.rb +48 -0
- data/lib/rack/handler/puma.rb +2 -3
- data/lib/rack/version_restriction.rb +15 -0
- data/tools/{docker/Dockerfile → Dockerfile} +1 -1
- metadata +29 -24
- data/docs/tcp_mode.md +0 -96
- data/ext/puma_http11/io_buffer.c +0 -155
- data/ext/puma_http11/org/jruby/puma/IOBuffer.java +0 -72
- data/lib/puma/accept_nonblock.rb +0 -29
- data/lib/puma/tcp_logger.rb +0 -41
- data/tools/jungle/README.md +0 -19
- data/tools/jungle/init.d/README.md +0 -61
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -69
- /data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
data/tools/jungle/init.d/puma
DELETED
@@ -1,421 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
### BEGIN INIT INFO
|
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
|
-
### END INIT INFO
|
12
|
-
|
13
|
-
# Author: Darío Javier Cravero <dario@exordo.com>
|
14
|
-
#
|
15
|
-
# Do NOT "set -e"
|
16
|
-
|
17
|
-
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
18
|
-
PATH=/usr/local/bin:/usr/local/sbin/:/sbin:/usr/sbin:/bin:/usr/bin
|
19
|
-
DESC="Puma rack web server"
|
20
|
-
NAME=puma
|
21
|
-
DAEMON=$NAME
|
22
|
-
SCRIPTNAME=/etc/init.d/$NAME
|
23
|
-
CONFIG=/etc/puma.conf
|
24
|
-
JUNGLE=`cat $CONFIG`
|
25
|
-
RUNPUMA=/usr/local/bin/run-puma
|
26
|
-
USE_LOCAL_BUNDLE=0
|
27
|
-
|
28
|
-
# Load the VERBOSE setting and other rcS variables
|
29
|
-
. /lib/init/vars.sh
|
30
|
-
|
31
|
-
# Define LSB log_* functions.
|
32
|
-
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
33
|
-
. /lib/lsb/init-functions
|
34
|
-
|
35
|
-
#
|
36
|
-
# Function that starts the jungle
|
37
|
-
#
|
38
|
-
do_start() {
|
39
|
-
log_daemon_msg "=> Running the jungle..."
|
40
|
-
for i in $JUNGLE; do
|
41
|
-
dir=`echo $i | cut -d , -f 1`
|
42
|
-
do_start_one $dir
|
43
|
-
done
|
44
|
-
}
|
45
|
-
|
46
|
-
do_start_one() {
|
47
|
-
PIDFILE=$1/tmp/puma/pid
|
48
|
-
if [ -e $PIDFILE ]; then
|
49
|
-
PID=`cat $PIDFILE`
|
50
|
-
# If the puma is running, restart it, otherwise run it.
|
51
|
-
if ps -p $PID > /dev/null; then
|
52
|
-
do_restart_one $1
|
53
|
-
else
|
54
|
-
do_start_one_do $1
|
55
|
-
fi
|
56
|
-
else
|
57
|
-
do_start_one_do $1
|
58
|
-
fi
|
59
|
-
}
|
60
|
-
|
61
|
-
do_start_one_do() {
|
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
|
87
|
-
}
|
88
|
-
|
89
|
-
#
|
90
|
-
# Function that stops the jungle
|
91
|
-
#
|
92
|
-
do_stop() {
|
93
|
-
log_daemon_msg "=> Putting all the beasts to bed..."
|
94
|
-
for i in $JUNGLE; do
|
95
|
-
dir=`echo $i | cut -d , -f 1`
|
96
|
-
do_stop_one $dir
|
97
|
-
done
|
98
|
-
}
|
99
|
-
#
|
100
|
-
# Function that stops the daemon/service
|
101
|
-
#
|
102
|
-
do_stop_one() {
|
103
|
-
log_daemon_msg "--> Stopping $1"
|
104
|
-
PIDFILE=$1/tmp/puma/pid
|
105
|
-
STATEFILE=$1/tmp/puma/state
|
106
|
-
if [ -e $PIDFILE ]; then
|
107
|
-
PID=`cat $PIDFILE`
|
108
|
-
if ps -p $PID > /dev/null; then
|
109
|
-
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
110
|
-
if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then
|
111
|
-
cd $1 && bundle exec pumactl --state $STATEFILE stop
|
112
|
-
else
|
113
|
-
pumactl --state $STATEFILE stop
|
114
|
-
fi
|
115
|
-
# Many daemons don't delete their pidfiles when they exit.
|
116
|
-
rm -f $PIDFILE $STATEFILE
|
117
|
-
else
|
118
|
-
log_daemon_msg "---> Puma $1 isn't running."
|
119
|
-
fi
|
120
|
-
else
|
121
|
-
log_daemon_msg "---> No puma here..."
|
122
|
-
fi
|
123
|
-
return 0
|
124
|
-
}
|
125
|
-
|
126
|
-
#
|
127
|
-
# Function that restarts the jungle
|
128
|
-
#
|
129
|
-
do_restart() {
|
130
|
-
for i in $JUNGLE; do
|
131
|
-
dir=`echo $i | cut -d , -f 1`
|
132
|
-
do_restart_one $dir
|
133
|
-
done
|
134
|
-
}
|
135
|
-
|
136
|
-
#
|
137
|
-
# Function that sends a SIGUSR2 to the daemon/service
|
138
|
-
#
|
139
|
-
do_restart_one() {
|
140
|
-
PIDFILE=$1/tmp/puma/pid
|
141
|
-
|
142
|
-
if [ -e $PIDFILE ]; then
|
143
|
-
log_daemon_msg "--> About to restart puma $1"
|
144
|
-
kill -s USR2 `cat $PIDFILE`
|
145
|
-
# TODO Check if process exist
|
146
|
-
else
|
147
|
-
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
148
|
-
do_start_one $1
|
149
|
-
fi
|
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/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
|
178
|
-
}
|
179
|
-
|
180
|
-
#
|
181
|
-
# Function that statuss the jungle
|
182
|
-
#
|
183
|
-
do_status() {
|
184
|
-
for i in $JUNGLE; do
|
185
|
-
dir=`echo $i | cut -d , -f 1`
|
186
|
-
do_status_one $dir
|
187
|
-
done
|
188
|
-
}
|
189
|
-
|
190
|
-
#
|
191
|
-
# Function that sends a SIGUSR2 to the daemon/service
|
192
|
-
#
|
193
|
-
do_status_one() {
|
194
|
-
PIDFILE=$1/tmp/puma/pid
|
195
|
-
i=`grep $1 $CONFIG`
|
196
|
-
dir=`echo $i | cut -d , -f 1`
|
197
|
-
|
198
|
-
if [ -e $PIDFILE ]; then
|
199
|
-
log_daemon_msg "--> About to status puma $1"
|
200
|
-
if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then
|
201
|
-
cd $1 && bundle exec pumactl --state $dir/tmp/puma/state stats
|
202
|
-
else
|
203
|
-
pumactl --state $dir/tmp/puma/state stats
|
204
|
-
fi
|
205
|
-
# kill -s USR2 `cat $PIDFILE`
|
206
|
-
# TODO Check if process exist
|
207
|
-
else
|
208
|
-
log_daemon_msg "--> $1 isn't there :(..."
|
209
|
-
fi
|
210
|
-
return 0
|
211
|
-
}
|
212
|
-
|
213
|
-
do_add() {
|
214
|
-
str=""
|
215
|
-
# App's directory
|
216
|
-
if [ -d "$1" ]; then
|
217
|
-
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
218
|
-
str=$1
|
219
|
-
else
|
220
|
-
echo "The app is already being managed. Remove it if you want to update its config."
|
221
|
-
exit 1
|
222
|
-
fi
|
223
|
-
else
|
224
|
-
echo "The directory $1 doesn't exist."
|
225
|
-
exit 1
|
226
|
-
fi
|
227
|
-
# User to run it as
|
228
|
-
if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then
|
229
|
-
echo "The user $2 doesn't exist."
|
230
|
-
exit 1
|
231
|
-
else
|
232
|
-
str="$str,$2"
|
233
|
-
fi
|
234
|
-
# Config file
|
235
|
-
if [ "$3" != "" ]; then
|
236
|
-
if [ -e $3 ]; then
|
237
|
-
str="$str,$3"
|
238
|
-
else
|
239
|
-
echo "The config file $3 doesn't exist."
|
240
|
-
exit 1
|
241
|
-
fi
|
242
|
-
fi
|
243
|
-
# Log file
|
244
|
-
if [ "$4" != "" ]; then
|
245
|
-
str="$str,$4"
|
246
|
-
fi
|
247
|
-
|
248
|
-
# Environment variables
|
249
|
-
if [ "$5" != "" ]; then
|
250
|
-
str="$str,$5"
|
251
|
-
fi
|
252
|
-
|
253
|
-
# Add it to the jungle
|
254
|
-
echo $str >> $CONFIG
|
255
|
-
log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
|
256
|
-
}
|
257
|
-
|
258
|
-
do_remove() {
|
259
|
-
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
260
|
-
echo "There's no app $1 to remove."
|
261
|
-
else
|
262
|
-
# Stop it first.
|
263
|
-
do_stop_one $1
|
264
|
-
# Remove it from the config.
|
265
|
-
sed -i "\\:^$1:d" $CONFIG
|
266
|
-
log_daemon_msg "Removed a Puma from the jungle: $1."
|
267
|
-
fi
|
268
|
-
}
|
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
|
-
|
313
|
-
case "$1" in
|
314
|
-
start)
|
315
|
-
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
316
|
-
if [ "$#" -eq 1 ]; then
|
317
|
-
do_start
|
318
|
-
else
|
319
|
-
i=`grep $2 $CONFIG`
|
320
|
-
dir=`echo $i | cut -d , -f 1`
|
321
|
-
do_start_one $dir
|
322
|
-
fi
|
323
|
-
case "$?" in
|
324
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
325
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
326
|
-
esac
|
327
|
-
;;
|
328
|
-
stop)
|
329
|
-
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
330
|
-
if [ "$#" -eq 1 ]; then
|
331
|
-
do_stop
|
332
|
-
else
|
333
|
-
i=`grep $2 $CONFIG`
|
334
|
-
dir=`echo $i | cut -d , -f 1`
|
335
|
-
do_stop_one $dir
|
336
|
-
fi
|
337
|
-
case "$?" in
|
338
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
339
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
340
|
-
esac
|
341
|
-
;;
|
342
|
-
status)
|
343
|
-
# TODO Implement.
|
344
|
-
log_daemon_msg "Status $DESC" "$NAME"
|
345
|
-
if [ "$#" -eq 1 ]; then
|
346
|
-
do_status
|
347
|
-
else
|
348
|
-
i=`grep $2 $CONFIG`
|
349
|
-
dir=`echo $i | cut -d , -f 1`
|
350
|
-
do_status_one $dir
|
351
|
-
fi
|
352
|
-
case "$?" in
|
353
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
354
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
355
|
-
esac
|
356
|
-
;;
|
357
|
-
restart)
|
358
|
-
log_daemon_msg "Restarting $DESC" "$NAME"
|
359
|
-
if [ "$#" -eq 1 ]; then
|
360
|
-
do_restart
|
361
|
-
else
|
362
|
-
i=`grep $2 $CONFIG`
|
363
|
-
dir=`echo $i | cut -d , -f 1`
|
364
|
-
do_restart_one $dir
|
365
|
-
fi
|
366
|
-
case "$?" in
|
367
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
368
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
369
|
-
esac
|
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
|
-
;;
|
385
|
-
add)
|
386
|
-
if [ "$#" -lt 3 ]; then
|
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."
|
390
|
-
exit 1
|
391
|
-
else
|
392
|
-
do_add $2 $3 $4 $5
|
393
|
-
fi
|
394
|
-
case "$?" in
|
395
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
396
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
397
|
-
esac
|
398
|
-
;;
|
399
|
-
remove)
|
400
|
-
if [ "$#" -lt 2 ]; then
|
401
|
-
echo "Please, specify the app's directory to remove."
|
402
|
-
exit 1
|
403
|
-
else
|
404
|
-
do_remove $2
|
405
|
-
fi
|
406
|
-
case "$?" in
|
407
|
-
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
408
|
-
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
409
|
-
esac
|
410
|
-
;;
|
411
|
-
*)
|
412
|
-
echo "Usage:" >&2
|
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
|
418
|
-
exit 3
|
419
|
-
;;
|
420
|
-
esac
|
421
|
-
:
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# on system boot, and root have no rbenv installed,
|
4
|
-
# after start-stop-daemon switched to current user, we have to init rbenv
|
5
|
-
if [ -d "$HOME/.rbenv/bin" ]; then
|
6
|
-
PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
7
|
-
eval "$(rbenv init -)"
|
8
|
-
elif [ -d "/usr/local/rbenv/bin" ]; then
|
9
|
-
PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
|
10
|
-
eval "$(rbenv init -)"
|
11
|
-
elif [ -f /usr/local/rvm/scripts/rvm ]; then
|
12
|
-
source /etc/profile.d/rvm.sh
|
13
|
-
elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
|
14
|
-
source "$HOME/.rvm/scripts/rvm"
|
15
|
-
fi
|
16
|
-
|
17
|
-
app=$1; config=$2; log=$3;
|
18
|
-
cd $app && exec bundle exec puma -C $config >> $log 2>&1
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# Puma as a service using Upstart
|
2
|
-
|
3
|
-
Manage multiple Puma servers as services on the same box using Ubuntu upstart.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
# Copy the scripts to services directory
|
8
|
-
sudo cp puma.conf puma-manager.conf /etc/init
|
9
|
-
|
10
|
-
# Create an empty configuration file
|
11
|
-
sudo touch /etc/puma.conf
|
12
|
-
|
13
|
-
## Managing the jungle
|
14
|
-
|
15
|
-
Puma apps are referenced in /etc/puma.conf by default. Add each app's path as a new line, e.g.:
|
16
|
-
|
17
|
-
```
|
18
|
-
/home/apps/my-cool-ruby-app
|
19
|
-
/home/apps/another-app/current
|
20
|
-
```
|
21
|
-
|
22
|
-
Start the jungle running:
|
23
|
-
|
24
|
-
`sudo start puma-manager`
|
25
|
-
|
26
|
-
This script will run at boot time.
|
27
|
-
|
28
|
-
Start a single puma like this:
|
29
|
-
|
30
|
-
`sudo start puma app=/path/to/app`
|
31
|
-
|
32
|
-
## Logs
|
33
|
-
|
34
|
-
Everything is logged by upstart, defaulting to `/var/log/upstart`.
|
35
|
-
|
36
|
-
Each puma instance is named after its directory, so for an app called `/home/apps/my-app` the log file would be `/var/log/upstart/puma-_home_apps_my-app.log`.
|
37
|
-
|
38
|
-
## Conventions
|
39
|
-
|
40
|
-
* The script expects:
|
41
|
-
* a config file to exist under `config/puma.rb` in your app. E.g.: `/home/apps/my-app/config/puma.rb`.
|
42
|
-
* a temporary folder to put the PID, socket and state files to exist called `tmp/puma`. E.g.: `/home/apps/my-app/tmp/puma`. Puma will take care of the files for you.
|
43
|
-
|
44
|
-
You can always change those defaults by editing the scripts.
|
45
|
-
|
46
|
-
## Here's what a minimal app's config file should have
|
47
|
-
|
48
|
-
```
|
49
|
-
pidfile "/path/to/app/tmp/puma/pid"
|
50
|
-
state_path "/path/to/app/tmp/puma/state"
|
51
|
-
activate_control_app
|
52
|
-
```
|
53
|
-
|
54
|
-
## Before starting...
|
55
|
-
|
56
|
-
You need to customise `puma.conf` to:
|
57
|
-
|
58
|
-
* Set the right user your app should be running on unless you want root to execute it!
|
59
|
-
* Look for `setuid apps` and `setgid apps`, uncomment those lines and replace `apps` to whatever your deployment user is.
|
60
|
-
* Replace `apps` on the paths (or set the right paths to your user's home) everywhere else.
|
61
|
-
* Uncomment the source lines for `rbenv` or `rvm` support unless you use a system wide installation of Ruby.
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# /etc/init/puma-manager.conf - manage a set of Pumas
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 12.04+. It
|
4
|
-
# allows you to manage multiple Puma instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See puma.conf for how to manage a single Puma instance.
|
8
|
-
#
|
9
|
-
# Use "stop puma-manager" to stop all Puma instances.
|
10
|
-
# Use "start puma-manager" to start all instances.
|
11
|
-
# Use "restart puma-manager" to restart all instances.
|
12
|
-
# Crazy, right?
|
13
|
-
#
|
14
|
-
|
15
|
-
description "Manages the set of puma processes"
|
16
|
-
|
17
|
-
# This starts upon bootup and stops on shutdown
|
18
|
-
start on runlevel [2345]
|
19
|
-
stop on runlevel [06]
|
20
|
-
|
21
|
-
# Set this to the number of Puma processes you want
|
22
|
-
# to run on this machine
|
23
|
-
env PUMA_CONF="/etc/puma.conf"
|
24
|
-
|
25
|
-
pre-start script
|
26
|
-
for i in `cat $PUMA_CONF`; do
|
27
|
-
app=`echo $i | cut -d , -f 1`
|
28
|
-
logger -t "puma-manager" "Starting $app"
|
29
|
-
start puma app=$app
|
30
|
-
done
|
31
|
-
end script
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# /etc/init/puma.conf - Puma config
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 12.04+. It
|
4
|
-
# allows you to manage multiple Puma instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See puma-manager.conf for how to manage all Puma instances at once.
|
8
|
-
#
|
9
|
-
# Save this config as /etc/init/puma.conf then manage puma with:
|
10
|
-
# sudo start puma app=PATH_TO_APP
|
11
|
-
# sudo stop puma app=PATH_TO_APP
|
12
|
-
# sudo status puma app=PATH_TO_APP
|
13
|
-
#
|
14
|
-
# or use the service command:
|
15
|
-
# sudo service puma {start,stop,restart,status}
|
16
|
-
#
|
17
|
-
|
18
|
-
description "Puma Background Worker"
|
19
|
-
|
20
|
-
# no "start on", we don't want to automatically start
|
21
|
-
stop on (stopping puma-manager or runlevel [06])
|
22
|
-
|
23
|
-
# change apps to match your deployment user if you want to use this as a less privileged user (recommended!)
|
24
|
-
setuid apps
|
25
|
-
setgid apps
|
26
|
-
|
27
|
-
respawn
|
28
|
-
respawn limit 3 30
|
29
|
-
|
30
|
-
instance ${app}
|
31
|
-
|
32
|
-
script
|
33
|
-
# this script runs in /bin/sh by default
|
34
|
-
# respawn as bash so we can source in rbenv/rvm
|
35
|
-
# quoted heredoc to tell /bin/sh not to interpret
|
36
|
-
# variables
|
37
|
-
|
38
|
-
# source ENV variables manually as Upstart doesn't, eg:
|
39
|
-
#. /etc/environment
|
40
|
-
|
41
|
-
exec /bin/bash <<'EOT'
|
42
|
-
# set HOME to the setuid user's home, there doesn't seem to be a better, portable way
|
43
|
-
export HOME="$(eval echo ~$(id -un))"
|
44
|
-
|
45
|
-
if [ -d "/usr/local/rbenv/bin" ]; then
|
46
|
-
export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
|
47
|
-
elif [ -d "$HOME/.rbenv/bin" ]; then
|
48
|
-
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
49
|
-
elif [ -f /etc/profile.d/rvm.sh ]; then
|
50
|
-
source /etc/profile.d/rvm.sh
|
51
|
-
elif [ -f /usr/local/rvm/scripts/rvm ]; then
|
52
|
-
source /etc/profile.d/rvm.sh
|
53
|
-
elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
|
54
|
-
source "$HOME/.rvm/scripts/rvm"
|
55
|
-
elif [ -f /usr/local/share/chruby/chruby.sh ]; then
|
56
|
-
source /usr/local/share/chruby/chruby.sh
|
57
|
-
if [ -f /usr/local/share/chruby/auto.sh ]; then
|
58
|
-
source /usr/local/share/chruby/auto.sh
|
59
|
-
fi
|
60
|
-
# if you aren't using auto, set your version here
|
61
|
-
# chruby 2.0.0
|
62
|
-
fi
|
63
|
-
|
64
|
-
cd $app
|
65
|
-
logger -t puma "Starting server: $app"
|
66
|
-
|
67
|
-
exec bundle exec puma -C config/puma.rb
|
68
|
-
EOT
|
69
|
-
end script
|
File without changes
|