我正在创建一个应用程序,其中Sinatra运行在EventMachine中,当我运行最基本的测试应用程序时,我无法使用Ctrl-C结束服务器,我必须使用-9或-usr2进行杀死。
我无法弄清楚为什么Sinatra报告已停止但继续提供请求,或者为什么我无法使用Ctrl-C停止服务器。
Thin 1.6.1与Sinatra 1.4.4已停止消息但继续。
这是我用来生成输出的基本测试应用程序。
我无法弄清楚为什么Sinatra报告已停止但继续提供请求,或者为什么我无法使用Ctrl-C停止服务器。
Thin 1.6.1与Sinatra 1.4.4已停止消息但继续。
== Sinatra/1.4.4 has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
Stopping ...
== Sinatra has ended his set (crowd applauds)
Ping!
^CPing!
Stopping ...
Ping!
^CStopping ...
这是我用来生成输出的基本测试应用程序。
# Run with 'ruby test.rb'
require 'eventmachine'
require 'sinatra/base'
require 'thin'
class NeverStops < Sinatra::Base
settings.logging = true
configure do
set :threaded, true
end
get '/foobar' do
'Foobar'
end
end
EM.run do
# Does nothing
#trap(:INT) { EM::stop(); exit }
#trap(:TERM) { EM::stop(); exit }
#trap(:KILL) { EM::stop(); exit }
EventMachine.add_periodic_timer 2 do
puts 'Ping!'
end
NeverStops.run!
end
降级Thin或Sinatra的结果不同。
Thin 1.6.1与Sinatra 1.4.3无停止消息但仍无法关闭(确实是“死亡证明”)
== Sinatra/1.4.3 has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
Ping!
^CPing!
Stopping ...
Ping!
Thin 1.5.1与Sinatra 1.4.4一起使用时会突然停止运行
== Sinatra/1.4.4 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
>> Stopping ...
== Sinatra has ended his set (crowd applauds)
Thin 1.5.1 和 Sinatra 1.4.3 可以正常工作
== Sinatra/1.4.3 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
Ping!
Ping!
Ping!
^C>> Stopping ...
== Sinatra has ended his set (crowd applauds)
我已经将我的gems更新到最新版本,尝试降低EventMachine和Rack等各种gem的版本以查看结果,但没有任何有用的不同。
版本
- OSX 10.8.5和Ubuntu 12.04.1
- Ruby 2.0.0p247和1.9.3p194
- eventmachine 1.0.3
- rack 1.5.2
- sinatra 1.4.4
- thin 1.6.1
- tilt 1.4.1