wendell-puma 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +55 -0
- data/DEPLOYMENT.md +92 -0
- data/Gemfile +17 -0
- data/History.txt +588 -0
- data/LICENSE +26 -0
- data/Manifest.txt +68 -0
- data/README.md +251 -0
- data/Rakefile +158 -0
- data/bin/puma +10 -0
- data/bin/puma-wild +31 -0
- data/bin/pumactl +12 -0
- data/docs/config.md +0 -0
- data/docs/nginx.md +80 -0
- data/docs/signals.md +43 -0
- data/ext/puma_http11/PumaHttp11Service.java +17 -0
- data/ext/puma_http11/ext_help.h +15 -0
- data/ext/puma_http11/extconf.rb +9 -0
- data/ext/puma_http11/http11_parser.c +1225 -0
- data/ext/puma_http11/http11_parser.h +64 -0
- data/ext/puma_http11/http11_parser.java.rl +161 -0
- data/ext/puma_http11/http11_parser.rl +146 -0
- data/ext/puma_http11/http11_parser_common.rl +54 -0
- data/ext/puma_http11/io_buffer.c +155 -0
- data/ext/puma_http11/mini_ssl.c +198 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +225 -0
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +488 -0
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +391 -0
- data/ext/puma_http11/puma_http11.c +491 -0
- data/lib/puma.rb +14 -0
- data/lib/puma/accept_nonblock.rb +23 -0
- data/lib/puma/app/status.rb +59 -0
- data/lib/puma/binder.rb +298 -0
- data/lib/puma/capistrano.rb +86 -0
- data/lib/puma/cli.rb +606 -0
- data/lib/puma/client.rb +289 -0
- data/lib/puma/cluster.rb +404 -0
- data/lib/puma/compat.rb +18 -0
- data/lib/puma/configuration.rb +377 -0
- data/lib/puma/const.rb +165 -0
- data/lib/puma/control_cli.rb +251 -0
- data/lib/puma/daemon_ext.rb +25 -0
- data/lib/puma/delegation.rb +11 -0
- data/lib/puma/detect.rb +4 -0
- data/lib/puma/events.rb +130 -0
- data/lib/puma/io_buffer.rb +7 -0
- data/lib/puma/java_io_buffer.rb +45 -0
- data/lib/puma/jruby_restart.rb +83 -0
- data/lib/puma/minissl.rb +187 -0
- data/lib/puma/null_io.rb +34 -0
- data/lib/puma/rack_default.rb +7 -0
- data/lib/puma/rack_patch.rb +45 -0
- data/lib/puma/reactor.rb +183 -0
- data/lib/puma/runner.rb +146 -0
- data/lib/puma/server.rb +801 -0
- data/lib/puma/single.rb +102 -0
- data/lib/puma/tcp_logger.rb +32 -0
- data/lib/puma/thread_pool.rb +185 -0
- data/lib/puma/util.rb +9 -0
- data/lib/rack/handler/puma.rb +66 -0
- data/test/test_app_status.rb +92 -0
- data/test/test_cli.rb +173 -0
- data/test/test_config.rb +26 -0
- data/test/test_http10.rb +27 -0
- data/test/test_http11.rb +144 -0
- data/test/test_integration.rb +165 -0
- data/test/test_iobuffer.rb +38 -0
- data/test/test_minissl.rb +29 -0
- data/test/test_null_io.rb +31 -0
- data/test/test_persistent.rb +238 -0
- data/test/test_puma_server.rb +288 -0
- data/test/test_puma_server_ssl.rb +137 -0
- data/test/test_rack_handler.rb +10 -0
- data/test/test_rack_server.rb +141 -0
- data/test/test_tcp_rack.rb +42 -0
- data/test/test_thread_pool.rb +156 -0
- data/test/test_unix_socket.rb +39 -0
- data/test/test_ws.rb +89 -0
- data/tools/jungle/README.md +9 -0
- data/tools/jungle/init.d/README.md +54 -0
- data/tools/jungle/init.d/puma +332 -0
- data/tools/jungle/init.d/run-puma +3 -0
- data/tools/jungle/upstart/README.md +61 -0
- data/tools/jungle/upstart/puma-manager.conf +31 -0
- data/tools/jungle/upstart/puma.conf +63 -0
- data/tools/trickletest.rb +45 -0
- data/wendell-puma.gemspec +55 -0
- metadata +225 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
require 'test/unit'
|
3
|
+
require 'puma/server'
|
4
|
+
|
5
|
+
require 'socket'
|
6
|
+
|
7
|
+
# UNIX sockets are not recommended on JRuby
|
8
|
+
# (or Windows)
|
9
|
+
unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
|
10
|
+
class TestPumaUnixSocket < Test::Unit::TestCase
|
11
|
+
|
12
|
+
App = lambda { |env| [200, {}, ["Works"]] }
|
13
|
+
|
14
|
+
Path = "test/puma.sock"
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@server = Puma::Server.new App
|
18
|
+
@server.add_unix_listener Path
|
19
|
+
@server.run
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
@server.stop(true)
|
24
|
+
File.unlink Path if File.exist? Path
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_server
|
28
|
+
sock = UNIXSocket.new Path
|
29
|
+
|
30
|
+
sock << "GET / HTTP/1.0\r\nHost: blah.com\r\n\r\n"
|
31
|
+
|
32
|
+
expected = "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Length: 5\r\n\r\nWorks"
|
33
|
+
|
34
|
+
assert_equal expected, sock.read(expected.size)
|
35
|
+
|
36
|
+
sock.close
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_ws.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright (c) 2011 Evan Phoenix
|
2
|
+
# Copyright (c) 2005 Zed A. Shaw
|
3
|
+
|
4
|
+
require 'test/testhelp'
|
5
|
+
|
6
|
+
include Puma
|
7
|
+
|
8
|
+
class TestHandler
|
9
|
+
attr_reader :ran_test
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
@ran_test = true
|
13
|
+
|
14
|
+
[200, {"Content-Type" => "text/plain"}, ["hello!"]]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class WebServerTest < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
|
22
|
+
|
23
|
+
@tester = TestHandler.new
|
24
|
+
|
25
|
+
@server = Server.new @tester, Events.strings
|
26
|
+
@server.add_tcp_listener "127.0.0.1", 9998
|
27
|
+
|
28
|
+
@server.run
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
@server.stop(true)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_simple_server
|
36
|
+
hit(['http://127.0.0.1:9998/test'])
|
37
|
+
assert @tester.ran_test, "Handler didn't really run"
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def do_test(string, chunk, close_after=nil, shutdown_delay=0)
|
42
|
+
# Do not use instance variables here, because it needs to be thread safe
|
43
|
+
socket = TCPSocket.new("127.0.0.1", 9998);
|
44
|
+
request = StringIO.new(string)
|
45
|
+
chunks_out = 0
|
46
|
+
|
47
|
+
while data = request.read(chunk)
|
48
|
+
chunks_out += socket.write(data)
|
49
|
+
socket.flush
|
50
|
+
sleep 0.2
|
51
|
+
if close_after and chunks_out > close_after
|
52
|
+
socket.close
|
53
|
+
sleep 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
sleep(shutdown_delay)
|
57
|
+
socket.write(" ") # Some platforms only raise the exception on attempted write
|
58
|
+
socket.flush
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_trickle_attack
|
62
|
+
do_test(@valid_request, 3)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_close_client
|
66
|
+
assert_raises IOError do
|
67
|
+
do_test(@valid_request, 10, 20)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_bad_client
|
72
|
+
do_test("GET /test HTTP/BAD", 3)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_header_is_too_long
|
76
|
+
long = "GET /test HTTP/1.1\r\n" + ("X-Big: stuff\r\n" * 15000) + "\r\n"
|
77
|
+
assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL, IOError do
|
78
|
+
do_test(long, long.length/2, 10)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_file_streamed_request
|
83
|
+
body = "a" * (Puma::Const::MAX_BODY * 2)
|
84
|
+
long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
|
85
|
+
do_test(long, (Puma::Const::CHUNK_SIZE * 2) - 400)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Puma daemon service
|
2
|
+
|
3
|
+
Init script to manage multiple Puma servers on the same box using start-stop-daemon.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
# Copy the init script to services directory
|
8
|
+
sudo cp puma /etc/init.d
|
9
|
+
sudo chmod +x /etc/init.d/puma
|
10
|
+
|
11
|
+
# Make it start at boot time.
|
12
|
+
sudo update-rc.d -f puma defaults
|
13
|
+
|
14
|
+
# Copy the Puma runner to an accessible location
|
15
|
+
sudo cp run-puma /usr/local/bin
|
16
|
+
sudo chmod +x /usr/local/bin/run-puma
|
17
|
+
|
18
|
+
# Create an empty configuration file
|
19
|
+
sudo touch /etc/puma.conf
|
20
|
+
|
21
|
+
## Managing the jungle
|
22
|
+
|
23
|
+
Puma apps are held in /etc/puma.conf by default. It's mainly a CSV file and every line represents one app. Here's the syntax:
|
24
|
+
|
25
|
+
app-path,user,config-file-path,log-file-path
|
26
|
+
|
27
|
+
You can add an instance by editing the file or running the following command:
|
28
|
+
|
29
|
+
sudo /etc/init.d/puma add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log
|
30
|
+
|
31
|
+
The config and log paths are optional parameters and default to:
|
32
|
+
|
33
|
+
* config: /path/to/app/*config/puma.rb*
|
34
|
+
* log: /path/to/app/*log/puma.log*
|
35
|
+
|
36
|
+
To remove an app, simply delete the line from the config file or run:
|
37
|
+
|
38
|
+
sudo /etc/init.d/puma remove /path/to/app
|
39
|
+
|
40
|
+
The command will make sure the Puma instance stops before removing it from the jungle.
|
41
|
+
|
42
|
+
## Assumptions
|
43
|
+
|
44
|
+
* The script expects a temporary folder named /path/to/app/*tmp/puma* to exist. Create it if it's not there by default.
|
45
|
+
The pid and state files should live there and must be called: *tmp/puma/pid* and *tmp/puma/state*.
|
46
|
+
You can change those if you want but you'll have to adapt the script for it to work.
|
47
|
+
|
48
|
+
* Here's what a minimal app's config file should have:
|
49
|
+
|
50
|
+
```
|
51
|
+
pidfile "/path/to/app/tmp/puma/pid"
|
52
|
+
state_path "/path/to/app/tmp/puma/state"
|
53
|
+
activate_control_app
|
54
|
+
```
|
@@ -0,0 +1,332 @@
|
|
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: Example initscript
|
9
|
+
# Description: This file should be used to construct scripts to be
|
10
|
+
# 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
|
+
|
27
|
+
# Load the VERBOSE setting and other rcS variables
|
28
|
+
. /lib/init/vars.sh
|
29
|
+
|
30
|
+
# Define LSB log_* functions.
|
31
|
+
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
32
|
+
. /lib/lsb/init-functions
|
33
|
+
|
34
|
+
#
|
35
|
+
# Function that starts the jungle
|
36
|
+
#
|
37
|
+
do_start() {
|
38
|
+
log_daemon_msg "=> Running the jungle..."
|
39
|
+
for i in $JUNGLE; do
|
40
|
+
dir=`echo $i | cut -d , -f 1`
|
41
|
+
user=`echo $i | cut -d , -f 2`
|
42
|
+
config_file=`echo $i | cut -d , -f 3`
|
43
|
+
if [ "$config_file" = "" ]; then
|
44
|
+
config_file="$dir/config/puma.rb"
|
45
|
+
fi
|
46
|
+
log_file=`echo $i | cut -d , -f 4`
|
47
|
+
if [ "$log_file" = "" ]; then
|
48
|
+
log_file="$dir/log/puma.log"
|
49
|
+
fi
|
50
|
+
do_start_one $dir $user $config_file $log_file
|
51
|
+
done
|
52
|
+
}
|
53
|
+
|
54
|
+
do_start_one() {
|
55
|
+
PIDFILE=$1/tmp/puma/pid
|
56
|
+
if [ -e $PIDFILE ]; then
|
57
|
+
PID=`cat $PIDFILE`
|
58
|
+
# If the puma isn't running, run it, otherwise restart it.
|
59
|
+
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
60
|
+
do_start_one_do $1 $2 $3 $4
|
61
|
+
else
|
62
|
+
do_restart_one $1
|
63
|
+
fi
|
64
|
+
else
|
65
|
+
do_start_one_do $1 $2 $3 $4
|
66
|
+
fi
|
67
|
+
}
|
68
|
+
|
69
|
+
do_start_one_do() {
|
70
|
+
log_daemon_msg "--> Woke up puma $1"
|
71
|
+
log_daemon_msg "user $2"
|
72
|
+
log_daemon_msg "log to $4"
|
73
|
+
start-stop-daemon --verbose --start --chdir $1 --chuid $2 --background --exec $RUNPUMA -- $1 $3 $4
|
74
|
+
}
|
75
|
+
|
76
|
+
#
|
77
|
+
# Function that stops the jungle
|
78
|
+
#
|
79
|
+
do_stop() {
|
80
|
+
log_daemon_msg "=> Putting all the beasts to bed..."
|
81
|
+
for i in $JUNGLE; do
|
82
|
+
dir=`echo $i | cut -d , -f 1`
|
83
|
+
do_stop_one $dir
|
84
|
+
done
|
85
|
+
}
|
86
|
+
#
|
87
|
+
# Function that stops the daemon/service
|
88
|
+
#
|
89
|
+
do_stop_one() {
|
90
|
+
log_daemon_msg "--> Stopping $1"
|
91
|
+
PIDFILE=$1/tmp/puma/pid
|
92
|
+
STATEFILE=$1/tmp/puma/state
|
93
|
+
if [ -e $PIDFILE ]; then
|
94
|
+
PID=`cat $PIDFILE`
|
95
|
+
if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
|
96
|
+
log_daemon_msg "---> Puma $1 isn't running."
|
97
|
+
else
|
98
|
+
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
99
|
+
pumactl --state $STATEFILE stop
|
100
|
+
# Many daemons don't delete their pidfiles when they exit.
|
101
|
+
rm -f $PIDFILE $STATEFILE
|
102
|
+
fi
|
103
|
+
else
|
104
|
+
log_daemon_msg "---> No puma here..."
|
105
|
+
fi
|
106
|
+
return 0
|
107
|
+
}
|
108
|
+
|
109
|
+
#
|
110
|
+
# Function that restarts the jungle
|
111
|
+
#
|
112
|
+
do_restart() {
|
113
|
+
for i in $JUNGLE; do
|
114
|
+
dir=`echo $i | cut -d , -f 1`
|
115
|
+
do_restart_one $dir
|
116
|
+
done
|
117
|
+
}
|
118
|
+
|
119
|
+
#
|
120
|
+
# Function that sends a SIGUSR2 to the daemon/service
|
121
|
+
#
|
122
|
+
do_restart_one() {
|
123
|
+
PIDFILE=$1/tmp/puma/pid
|
124
|
+
i=`grep $1 $CONFIG`
|
125
|
+
dir=`echo $i | cut -d , -f 1`
|
126
|
+
|
127
|
+
if [ -e $PIDFILE ]; then
|
128
|
+
log_daemon_msg "--> About to restart puma $1"
|
129
|
+
pumactl --state $dir/tmp/puma/state restart
|
130
|
+
# kill -s USR2 `cat $PIDFILE`
|
131
|
+
# TODO Check if process exist
|
132
|
+
else
|
133
|
+
log_daemon_msg "--> Your puma was never playing... Let's get it out there first"
|
134
|
+
user=`echo $i | cut -d , -f 2`
|
135
|
+
config_file=`echo $i | cut -d , -f 3`
|
136
|
+
if [ "$config_file" = "" ]; then
|
137
|
+
config_file="$dir/config/puma.rb"
|
138
|
+
fi
|
139
|
+
log_file=`echo $i | cut -d , -f 4`
|
140
|
+
if [ "$log_file" = "" ]; then
|
141
|
+
log_file="$dir/log/puma.log"
|
142
|
+
fi
|
143
|
+
do_start_one $dir $user $config_file $log_file
|
144
|
+
fi
|
145
|
+
return 0
|
146
|
+
}
|
147
|
+
|
148
|
+
#
|
149
|
+
# Function that statuss the jungle
|
150
|
+
#
|
151
|
+
do_status() {
|
152
|
+
for i in $JUNGLE; do
|
153
|
+
dir=`echo $i | cut -d , -f 1`
|
154
|
+
do_status_one $dir
|
155
|
+
done
|
156
|
+
}
|
157
|
+
|
158
|
+
#
|
159
|
+
# Function that sends a SIGUSR2 to the daemon/service
|
160
|
+
#
|
161
|
+
do_status_one() {
|
162
|
+
PIDFILE=$1/tmp/puma/pid
|
163
|
+
i=`grep $1 $CONFIG`
|
164
|
+
dir=`echo $i | cut -d , -f 1`
|
165
|
+
|
166
|
+
if [ -e $PIDFILE ]; then
|
167
|
+
log_daemon_msg "--> About to status puma $1"
|
168
|
+
pumactl --state $dir/tmp/puma/state stats
|
169
|
+
# kill -s USR2 `cat $PIDFILE`
|
170
|
+
# TODO Check if process exist
|
171
|
+
else
|
172
|
+
log_daemon_msg "--> $1 isn't there :(..."
|
173
|
+
fi
|
174
|
+
return 0
|
175
|
+
}
|
176
|
+
|
177
|
+
do_add() {
|
178
|
+
str=""
|
179
|
+
# App's directory
|
180
|
+
if [ -d "$1" ]; then
|
181
|
+
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
182
|
+
str=$1
|
183
|
+
else
|
184
|
+
echo "The app is already being managed. Remove it if you want to update its config."
|
185
|
+
exit 1
|
186
|
+
fi
|
187
|
+
else
|
188
|
+
echo "The directory $1 doesn't exist."
|
189
|
+
exit 1
|
190
|
+
fi
|
191
|
+
# User to run it as
|
192
|
+
if [ "`grep -c "^$2:" /etc/passwd`" -eq 0 ]; then
|
193
|
+
echo "The user $2 doesn't exist."
|
194
|
+
exit 1
|
195
|
+
else
|
196
|
+
str="$str,$2"
|
197
|
+
fi
|
198
|
+
# Config file
|
199
|
+
if [ "$3" != "" ]; then
|
200
|
+
if [ -e $3 ]; then
|
201
|
+
str="$str,$3"
|
202
|
+
else
|
203
|
+
echo "The config file $3 doesn't exist."
|
204
|
+
exit 1
|
205
|
+
fi
|
206
|
+
fi
|
207
|
+
# Log file
|
208
|
+
if [ "$4" != "" ]; then
|
209
|
+
str="$str,$4"
|
210
|
+
fi
|
211
|
+
|
212
|
+
# Add it to the jungle
|
213
|
+
echo $str >> $CONFIG
|
214
|
+
log_daemon_msg "Added a Puma to the jungle: $str. You still have to start it though."
|
215
|
+
}
|
216
|
+
|
217
|
+
do_remove() {
|
218
|
+
if [ "`grep -c "^$1" $CONFIG`" -eq 0 ]; then
|
219
|
+
echo "There's no app $1 to remove."
|
220
|
+
else
|
221
|
+
# Stop it first.
|
222
|
+
do_stop_one $1
|
223
|
+
# Remove it from the config.
|
224
|
+
sed -i "\\:^$1:d" $CONFIG
|
225
|
+
log_daemon_msg "Removed a Puma from the jungle: $1."
|
226
|
+
fi
|
227
|
+
}
|
228
|
+
|
229
|
+
case "$1" in
|
230
|
+
start)
|
231
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
232
|
+
if [ "$#" -eq 1 ]; then
|
233
|
+
do_start
|
234
|
+
else
|
235
|
+
i=`grep $2 $CONFIG`
|
236
|
+
dir=`echo $i | cut -d , -f 1`
|
237
|
+
user=`echo $i | cut -d , -f 2`
|
238
|
+
config_file=`echo $i | cut -d , -f 3`
|
239
|
+
if [ "$config_file" = "" ]; then
|
240
|
+
config_file="$dir/config/puma.rb"
|
241
|
+
fi
|
242
|
+
log_file=`echo $i | cut -d , -f 4`
|
243
|
+
if [ "$log_file" = "" ]; then
|
244
|
+
log_file="$dir/log/puma.log"
|
245
|
+
fi
|
246
|
+
do_start_one $dir $user $config_file $log_file
|
247
|
+
fi
|
248
|
+
case "$?" in
|
249
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
250
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
251
|
+
esac
|
252
|
+
;;
|
253
|
+
stop)
|
254
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
255
|
+
if [ "$#" -eq 1 ]; then
|
256
|
+
do_stop
|
257
|
+
else
|
258
|
+
i=`grep $2 $CONFIG`
|
259
|
+
dir=`echo $i | cut -d , -f 1`
|
260
|
+
do_stop_one $dir
|
261
|
+
fi
|
262
|
+
case "$?" in
|
263
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
264
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
265
|
+
esac
|
266
|
+
;;
|
267
|
+
status)
|
268
|
+
# TODO Implement.
|
269
|
+
log_daemon_msg "Status $DESC" "$NAME"
|
270
|
+
if [ "$#" -eq 1 ]; then
|
271
|
+
do_status
|
272
|
+
else
|
273
|
+
i=`grep $2 $CONFIG`
|
274
|
+
dir=`echo $i | cut -d , -f 1`
|
275
|
+
do_status_one $dir
|
276
|
+
fi
|
277
|
+
case "$?" in
|
278
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
279
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
280
|
+
esac
|
281
|
+
;;
|
282
|
+
restart)
|
283
|
+
log_daemon_msg "Restarting $DESC" "$NAME"
|
284
|
+
if [ "$#" -eq 1 ]; then
|
285
|
+
do_restart
|
286
|
+
else
|
287
|
+
i=`grep $2 $CONFIG`
|
288
|
+
dir=`echo $i | cut -d , -f 1`
|
289
|
+
do_restart_one $dir
|
290
|
+
fi
|
291
|
+
case "$?" in
|
292
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
293
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
294
|
+
esac
|
295
|
+
;;
|
296
|
+
add)
|
297
|
+
if [ "$#" -lt 3 ]; then
|
298
|
+
echo "Please, specifiy the app's directory and the user that will run it at least."
|
299
|
+
echo " Usage: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
300
|
+
echo " config and log are optionals."
|
301
|
+
exit 1
|
302
|
+
else
|
303
|
+
do_add $2 $3 $4 $5
|
304
|
+
fi
|
305
|
+
case "$?" in
|
306
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
307
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
308
|
+
esac
|
309
|
+
;;
|
310
|
+
remove)
|
311
|
+
if [ "$#" -lt 2 ]; then
|
312
|
+
echo "Please, specifiy the app's directory to remove."
|
313
|
+
exit 1
|
314
|
+
else
|
315
|
+
do_remove $2
|
316
|
+
fi
|
317
|
+
case "$?" in
|
318
|
+
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
319
|
+
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
320
|
+
esac
|
321
|
+
;;
|
322
|
+
*)
|
323
|
+
echo "Usage:" >&2
|
324
|
+
echo " Run the jungle: $SCRIPTNAME {start|stop|status|restart}" >&2
|
325
|
+
echo " Add a Puma: $SCRIPTNAME add /path/to/app user /path/to/app/config/puma.rb /path/to/app/config/log/puma.log"
|
326
|
+
echo " config and log are optionals."
|
327
|
+
echo " Remove a Puma: $SCRIPTNAME remove /path/to/app"
|
328
|
+
echo " On a Puma: $SCRIPTNAME {start|stop|status|restart} PUMA-NAME" >&2
|
329
|
+
exit 3
|
330
|
+
;;
|
331
|
+
esac
|
332
|
+
:
|