puma 2.1.1 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +3273 -0
  3. data/LICENSE +23 -20
  4. data/README.md +388 -100
  5. data/bin/puma-wild +25 -0
  6. data/bin/pumactl +1 -1
  7. data/docs/architecture.md +74 -0
  8. data/docs/compile_options.md +55 -0
  9. data/docs/deployment.md +137 -0
  10. data/docs/fork_worker.md +41 -0
  11. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  12. data/docs/images/puma-connection-flow.png +0 -0
  13. data/docs/images/puma-general-arch.png +0 -0
  14. data/docs/java_options.md +54 -0
  15. data/docs/jungle/README.md +9 -0
  16. data/docs/jungle/rc.d/README.md +74 -0
  17. data/docs/jungle/rc.d/puma +61 -0
  18. data/docs/jungle/rc.d/puma.conf +10 -0
  19. data/docs/kubernetes.md +73 -0
  20. data/docs/nginx.md +5 -5
  21. data/docs/plugins.md +42 -0
  22. data/docs/rails_dev_mode.md +28 -0
  23. data/docs/restart.md +65 -0
  24. data/docs/signals.md +98 -0
  25. data/docs/stats.md +148 -0
  26. data/docs/systemd.md +253 -0
  27. data/docs/testing_benchmarks_local_files.md +150 -0
  28. data/docs/testing_test_rackup_ci_files.md +36 -0
  29. data/ext/puma_http11/PumaHttp11Service.java +2 -2
  30. data/ext/puma_http11/extconf.rb +59 -2
  31. data/ext/puma_http11/http11_parser.c +319 -487
  32. data/ext/puma_http11/http11_parser.h +15 -13
  33. data/ext/puma_http11/http11_parser.java.rl +27 -43
  34. data/ext/puma_http11/http11_parser.rl +27 -24
  35. data/ext/puma_http11/http11_parser_common.rl +8 -8
  36. data/ext/puma_http11/mini_ssl.c +696 -38
  37. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  38. data/ext/puma_http11/org/jruby/puma/Http11.java +145 -113
  39. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +139 -172
  40. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +413 -193
  41. data/ext/puma_http11/puma_http11.c +183 -175
  42. data/lib/puma/app/status.rb +77 -29
  43. data/lib/puma/binder.rb +349 -119
  44. data/lib/puma/cli.rb +164 -769
  45. data/lib/puma/client.rb +591 -132
  46. data/lib/puma/cluster/worker.rb +183 -0
  47. data/lib/puma/cluster/worker_handle.rb +127 -0
  48. data/lib/puma/cluster.rb +634 -0
  49. data/lib/puma/cluster_accept_loop_delay.rb +91 -0
  50. data/lib/puma/commonlogger.rb +115 -0
  51. data/lib/puma/configuration.rb +370 -202
  52. data/lib/puma/const.rb +266 -115
  53. data/lib/puma/control_cli.rb +219 -120
  54. data/lib/puma/detect.rb +45 -2
  55. data/lib/puma/dsl.rb +1496 -0
  56. data/lib/puma/error_logger.rb +115 -0
  57. data/lib/puma/events.rb +44 -60
  58. data/lib/puma/io_buffer.rb +48 -5
  59. data/lib/puma/jruby_restart.rb +2 -51
  60. data/lib/puma/json_serialization.rb +96 -0
  61. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  62. data/lib/puma/launcher.rb +502 -0
  63. data/lib/puma/log_writer.rb +147 -0
  64. data/lib/puma/minissl/context_builder.rb +96 -0
  65. data/lib/puma/minissl.rb +355 -37
  66. data/lib/puma/null_io.rb +79 -12
  67. data/lib/puma/plugin/systemd.rb +90 -0
  68. data/lib/puma/plugin/tmp_restart.rb +36 -0
  69. data/lib/puma/plugin.rb +111 -0
  70. data/lib/puma/rack/builder.rb +297 -0
  71. data/lib/puma/rack/urlmap.rb +93 -0
  72. data/lib/puma/rack_default.rb +21 -4
  73. data/lib/puma/reactor.rb +102 -133
  74. data/lib/puma/request.rb +703 -0
  75. data/lib/puma/runner.rb +211 -0
  76. data/lib/puma/sd_notify.rb +146 -0
  77. data/lib/puma/server.rb +544 -436
  78. data/lib/puma/single.rb +72 -0
  79. data/lib/puma/state_file.rb +69 -0
  80. data/lib/puma/thread_pool.rb +282 -56
  81. data/lib/puma/util.rb +125 -0
  82. data/lib/puma.rb +80 -6
  83. data/lib/rack/handler/puma.rb +125 -47
  84. data/tools/Dockerfile +26 -0
  85. data/tools/trickletest.rb +44 -0
  86. metadata +77 -148
  87. data/COPYING +0 -55
  88. data/Gemfile +0 -10
  89. data/History.txt +0 -291
  90. data/Manifest.txt +0 -60
  91. data/Rakefile +0 -121
  92. data/TODO +0 -5
  93. data/docs/config.md +0 -0
  94. data/ext/puma_http11/ext_help.h +0 -15
  95. data/ext/puma_http11/io_buffer.c +0 -154
  96. data/lib/puma/accept_nonblock.rb +0 -23
  97. data/lib/puma/capistrano.rb +0 -34
  98. data/lib/puma/compat.rb +0 -11
  99. data/lib/puma/daemon_ext.rb +0 -20
  100. data/lib/puma/delegation.rb +0 -11
  101. data/lib/puma/java_io_buffer.rb +0 -45
  102. data/lib/puma/rack_patch.rb +0 -25
  103. data/puma.gemspec +0 -45
  104. data/test/test_app_status.rb +0 -88
  105. data/test/test_cli.rb +0 -171
  106. data/test/test_config.rb +0 -16
  107. data/test/test_http10.rb +0 -27
  108. data/test/test_http11.rb +0 -126
  109. data/test/test_integration.rb +0 -154
  110. data/test/test_iobuffer.rb +0 -38
  111. data/test/test_minissl.rb +0 -25
  112. data/test/test_null_io.rb +0 -31
  113. data/test/test_persistent.rb +0 -238
  114. data/test/test_puma_server.rb +0 -207
  115. data/test/test_rack_handler.rb +0 -10
  116. data/test/test_rack_server.rb +0 -141
  117. data/test/test_thread_pool.rb +0 -146
  118. data/test/test_unix_socket.rb +0 -39
  119. data/test/test_ws.rb +0 -89
  120. data/tools/jungle/init.d/README.md +0 -54
  121. data/tools/jungle/init.d/puma +0 -332
  122. data/tools/jungle/init.d/run-puma +0 -3
  123. data/tools/jungle/upstart/README.md +0 -61
  124. data/tools/jungle/upstart/puma-manager.conf +0 -31
  125. data/tools/jungle/upstart/puma.conf +0 -52
@@ -1,146 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'puma/thread_pool'
4
-
5
- class TestThreadPool < Test::Unit::TestCase
6
-
7
- def teardown
8
- @pool.shutdown if @pool
9
- end
10
-
11
- def new_pool(min, max, &blk)
12
- blk = proc { } unless blk
13
- @pool = Puma::ThreadPool.new(min, max, &blk)
14
- end
15
-
16
- def pause
17
- sleep 0.2
18
- end
19
-
20
- def test_append_spawns
21
- saw = []
22
-
23
- pool = new_pool(0, 1) do |work|
24
- saw << work
25
- end
26
-
27
- pool << 1
28
-
29
- pause
30
-
31
- assert_equal [1], saw
32
- assert_equal 1, pool.spawned
33
- end
34
-
35
- def test_append_queues_on_max
36
- finish = false
37
- pool = new_pool(0, 1) { Thread.pass until finish }
38
-
39
- pool << 1
40
- pool << 2
41
- pool << 3
42
-
43
- pause
44
-
45
- assert_equal 2, pool.backlog
46
-
47
- finish = true
48
- end
49
-
50
- def test_trim
51
- pool = new_pool(0, 1)
52
-
53
- pool << 1
54
-
55
- pause
56
-
57
- assert_equal 1, pool.spawned
58
- pool.trim
59
-
60
- pause
61
- assert_equal 0, pool.spawned
62
- end
63
-
64
- def test_trim_leaves_min
65
- finish = false
66
- pool = new_pool(1, 2) { Thread.pass until finish }
67
-
68
- pool << 1
69
- pool << 2
70
-
71
- finish = true
72
-
73
- pause
74
-
75
- assert_equal 2, pool.spawned
76
- pool.trim
77
- pause
78
-
79
- assert_equal 1, pool.spawned
80
- pool.trim
81
- pause
82
-
83
- assert_equal 1, pool.spawned
84
-
85
- end
86
-
87
- def test_force_trim_doesnt_overtrim
88
- finish = false
89
- pool = new_pool(1, 2) { Thread.pass until finish }
90
-
91
- pool << 1
92
- pool << 2
93
-
94
- assert_equal 2, pool.spawned
95
- pool.trim true
96
- pool.trim true
97
-
98
- finish = true
99
-
100
- pause
101
-
102
- assert_equal 1, pool.spawned
103
- end
104
-
105
- def test_trim_is_ignored_if_no_waiting_threads
106
- finish = false
107
- pool = new_pool(1, 2) { Thread.pass until finish }
108
-
109
- pool << 1
110
- pool << 2
111
-
112
- assert_equal 2, pool.spawned
113
- pool.trim
114
- pool.trim
115
-
116
- assert_equal 0, pool.trim_requested
117
-
118
- finish = true
119
-
120
- pause
121
- end
122
-
123
- def test_autotrim
124
- finish = false
125
- pool = new_pool(1, 2) { Thread.pass until finish }
126
-
127
- pool << 1
128
- pool << 2
129
-
130
- assert_equal 2, pool.spawned
131
-
132
- finish = true
133
-
134
- pause
135
-
136
- assert_equal 2, pool.spawned
137
-
138
- pool.auto_trim! 1
139
-
140
- sleep 1
141
-
142
- pause
143
-
144
- assert_equal 1, pool.spawned
145
- end
146
- end
@@ -1,39 +0,0 @@
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.exists? 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 DELETED
@@ -1,89 +0,0 @@
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
-
@@ -1,54 +0,0 @@
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/*config/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
- ```
@@ -1,332 +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: 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
- :
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
- app=$1; config=$2; log=$3;
3
- cd $app && exec bundle exec puma -C $config 2>&1 >> $log