我正在使用 ruby 开发游戏服务器,在测试期间我无法单独测试组件。我没有从我的启动器获得输出,只是服务器,所以我注释掉了服务器的初始化——但 Eclipse 仍然显示来自服务器的输出!
然后我转到命令行,假设 eclipse 正在查看错误的文件(git 之前把它弄乱了,但是正如你所看到的,堆栈跟踪显示它Server.rb
正在从第 5 行完整执行require_relative 'Server'
::
这是文件的文本内容:
class Launcher
puts "File saved at #{File.mtime($0)}"
require_relative 'Server'
require_relative 'Game'
#STDOUT.sync = true
puts "Launcher started"
#server = Server.new
print "server made"
game = Game.new
#serverThread = Thread.new{server.start()}
gameThread = Thread.new{game.start()}
while (running)
print "Stop? "
input = gets.chomp
if (input.equals?("yes"))
running = false
end
end
server.stop
game.stop
gameThread.join
serverThread.join
end
和终端输出:
C:\Users\gossfunkel\git\citadelserver\RubyCitadelServer>ruby Launcher.rb
File saved at 2013-06-22 18:16:44 +0100
Server starting up at 2013-06-22 18:16:47 +0100...
C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:20:in `recvfro
m': Interrupt
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:2
0:in `run'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:1
5:in `start'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:3
0:in `<class:Server>'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:1
:in `<top (required)>'
from Launcher.rb:5:in `require_relative'
from Launcher.rb:5:in `<class:Launcher>'
from Launcher.rb:1:in `<main>'
我如何在不发生这种情况的情况下要求文件,应该这样吗?