Permalink
Browse files

Merge pull request #108 from gpad/win-error

Win error
  • Loading branch information...
2 parents 680be41 + 8d33d33 commit 067f5737040d0a98a529f8a723e8c8a55d387a27 @evanphx evanphx committed Jun 22, 2012
Showing with 51 additions and 12 deletions.
  1. +14 −6 lib/puma/cli.rb
  2. +31 −0 test/test_cli.rb
  3. +5 −5 test/test_rack_server.rb
  4. +1 −1 test/test_ws.rb
View
@@ -419,14 +419,22 @@ def run
@status = status
end
- Signal.trap "SIGUSR2" do
- @restart = true
- server.begin_restart
+ begin
+ Signal.trap "SIGUSR2" do
+ @restart = true
+ server.begin_restart
+ end
+ rescue Exception
+ log "*** Sorry signal SIGUSR2 not implemented, restart feature disabled!"
end
- Signal.trap "SIGTERM" do
- log " - Gracefully stopping, waiting for requests to finish"
- server.stop false
+ begin
+ Signal.trap "SIGTERM" do
+ log " - Gracefully stopping, waiting for requests to finish"
+ server.stop false
+ end
+ rescue Exception
+ log "*** Sorry signal SIGTERM not implemented, gracefully stopping feature disabled!"
end
log "Use Ctrl-C to stop"
View
@@ -28,6 +28,37 @@ def test_pid_file
assert_equal File.read(@tmp_path).strip.to_i, Process.pid
end
+ def test_control_for_tcp
+ url = "tcp://127.0.0.1:9877/"
+ sin = StringIO.new
+ sout = StringIO.new
+ cli = Puma::CLI.new ["-b", "tcp://127.0.0.1:9876",
+ "--control", url,
+ "--control-token", "",
+ "test/lobster.ru"], sin, sout
+ cli.parse_options
+
+ thread_exception = nil
+ t = Thread.new do
+ begin
+ cli.run
+ rescue Exception => e
+ thread_exception = e
+ end
+ end
+
+ sleep 1
+
+ s = TCPSocket.new "127.0.0.1", 9877
+ s << "GET /stats HTTP/1.0\r\n\r\n"
+ body = s.read
+ assert_equal '{ "backlog": 0, "running": 0 }', body.split("\r\n").last
+
+ cli.stop
+ t.join
+ assert_equal nil, thread_exception
+ end
+
unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
def test_control
url = "unix://#{@tmp_path}"
View
@@ -66,7 +66,7 @@ def test_lint
@server.run
- hit(['http://localhost:9998/test'])
+ hit(['http://127.0.0.1:9998/test'])
stop
@@ -83,7 +83,7 @@ def test_large_post_body
big = "x" * (1024 * 16)
- Net::HTTP.post_form URI.parse('http://localhost:9998/test'),
+ Net::HTTP.post_form URI.parse('http://127.0.0.1:9998/test'),
{ "big" => big }
stop
@@ -98,7 +98,7 @@ def test_path_info
@server.app = lambda { |env| input = env; @simple.call(env) }
@server.run
- hit(['http://localhost:9998/test/a/b/c'])
+ hit(['http://127.0.0.1:9998/test/a/b/c'])
stop
@@ -115,7 +115,7 @@ def test_after_reply
@server.run
- hit(['http://localhost:9998/test'])
+ hit(['http://127.0.0.1:9998/test'])
stop
@@ -131,7 +131,7 @@ def test_common_logger
@server.run
- hit(['http://localhost:9998/test'])
+ hit(['http://127.0.0.1:9998/test'])
stop
View
@@ -37,7 +37,7 @@ def teardown
end
def test_simple_server
- hit(['http://localhost:9998/test'])
+ hit(['http://127.0.0.1:9998/test'])
assert @tester.ran_test, "Handler didn't really run"
end

0 comments on commit 067f573

Please sign in to comment.