0

我有如下代码:

Thread.new do
  builder = Rack::Builder.new do
    map('/'){ run Server }
  end
  Rack::Handler::Thin.run builder, :Port => 8585
end
#how do i detect, that Server is running here (or wait for it)

我如何检测到服务器正在运行并能够接收请求?

谢谢

4

2 回答 2

1

您可以使用该defined?方法来检查这一点,例如

if defined? Rack::Handler::Thin
   # We're running under Thin. Do stuff.
else
   # nope :(
end
于 2012-05-18T03:41:28.953 回答
0

curl在终端中使用。curl http://yourapp.com:8585/如果这返回页面'/',则服务器已启动。

于 2012-05-18T03:20:02.803 回答