简体   繁体   中英

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.

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:

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?

Other Information:

  • Windows 7

  • RubyMine v4.0.4

  • 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.

I figured out what I was doing wrong and if I posted all 700 lines of the script you would have to. 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). 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.

Edit

The reason it was checking to see if it was itself was so that other scripts could require it and reuse the class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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