简体   繁体   English

如何从Ruby脚本在Rubymine控制台中启动WEBrick服务器

[英]How to Start WEBrick Server in Rubymine Console from Ruby Script

I have Ruby script that creates a proxy so that I can make HTTP request to a server from the command line using a session ID that the server expects. 我有创建代理的Ruby脚本,以便可以使用服务器期望的会话ID从命令行向服务器发出HTTP请求。

First of all, the script works great when I run it from the command line 首先,当我从命令行运行脚本时,脚本运行良好

@web_server_thread = Thread.start do
  puts "Starting local proxy on port #{@port}"
  Rack::Handler::WEBrick.run WebServerProxy.new(@port, @host, @secure, @port2,    @default_module_host, @cookie) , :Port => @port
end

Returns 退货

Starting local proxy on port 9292
[2012-06-15 11:29:03] INFO  WEBrick 1.3.1
[2012-06-15 11:29:03] INFO  ruby 1.9.3 (2012-04-20) [i386-mingw32]
[2012-06-15 11:29:03] INFO  WEBrick::HTTPServer#start: pid=6856 port=9292

I have been trying run this in RubyMine and the output in the console is always just: 我一直在尝试在RubyMine中运行它,控制台中的输出始终只是:

Process finished with exit code 0

Question: 题:

So my question is what can I do to configure RubyMine to run this script and if I cannot configure it to do so why not? 所以我的问题是我该如何配置RubyMine来运行该脚本,如果我不能配置它来执行该脚本,为什么不呢?

Other Information: 其他资讯:

  • Windows 7 Windows 7的

  • RubyMine v4.0.4 RubyMine v4.0.4

  • Ruby v1.9.3 Ruby v1.9.3

As I noted above this is running as expected from the command line, so I am simply looking for an explanation of reasons why this is not working in RubyMine. 正如我在上面指出的那样,它正在按预期的方式从命令行运行,因此我只是在寻找解释为什么在RubyMine中不起作用的原因。

I figured out what I was doing wrong and if I posted all 700 lines of the script you would have to. 我弄清楚我做错了什么,如果我发布了该脚本的全部700行,则必须这样做。 Prior to creating the thread above there was an if statement checking to make sure the name of the script was equal to a particular string (why I have no idea, I did not write this). 在上面创建线程之前,有一个if语句检查以确保脚本的名称等于特定的字符串(为什么我不知道,我没有写这个)。 When using RubyMine the name of the script included the full path on the server so that the logic starting the server never was executed using RubyMine but worked fine when I was using the command line. 当使用RubyMine时,脚本的名称包括服务器上的完整路径,因此启动服务器的逻辑从未使用RubyMine执行过,但是当我使用命令行时运行良好。

Edit 编辑

The reason it was checking to see if it was itself was so that other scripts could require it and reuse the class. 它检查它本身的原因是为了让其他脚本可能require它并重用该类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM