Class: Rapel::Runtime
- Inherits:
-
Object
- Object
- Rapel::Runtime
- Defined in:
- lib/rapel/runtime.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(callback_port, session_id) ⇒ Runtime
constructor
A new instance of Runtime.
- #inspect ⇒ Object
- #ruby_runtime_string(callback_port) ⇒ Object
- #shutdown ⇒ Object
- #start(pid) ⇒ Object
Constructor Details
#initialize(callback_port, session_id) ⇒ Runtime
Returns a new instance of Runtime.
8 9 10 11 12 13 |
# File 'lib/rapel/runtime.rb', line 8 def initialize(callback_port, session_id) runtime_port = 9220 @port = runtime_port @session_id = session_id system(ruby_runtime_string(callback_port)) end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/rapel/runtime.rb', line 5 def port @port end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
5 6 7 |
# File 'lib/rapel/runtime.rb', line 5 def session_id @session_id end |
#socket ⇒ Object
Returns the value of attribute socket.
6 7 8 |
# File 'lib/rapel/runtime.rb', line 6 def socket @socket end |
Instance Method Details
#inspect ⇒ Object
37 38 39 |
# File 'lib/rapel/runtime.rb', line 37 def inspect "\#<Runtime @session=\"#@session_id\" @ready=#@ready>" end |
#ruby_runtime_string(callback_port) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rapel/runtime.rb', line 15 def ruby_runtime_string(callback_port) ["ruby #{File.dirname(__FILE__)}/../../bin/runtime.rb", "--port=#{port}", "--callback-port=#{callback_port}", "--uuid=#{session_id}", "&"].join(" ") end |
#shutdown ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rapel/runtime.rb', line 23 def shutdown puts "killing at port #{port}" socket.puts("shutdown"+port.to_s) rescue puts "killing pid #{@pid}" `kill -9 #{@pid}` end |
#start(pid) ⇒ Object
31 32 33 34 35 |
# File 'lib/rapel/runtime.rb', line 31 def start(pid) @pid = pid @ready = true @socket = TCPSocket.new('localhost', port) end |