Class: Antigravity::Harness
- Inherits:
-
Object
- Object
- Antigravity::Harness
- Defined in:
- lib/antigravity/harness.rb
Instance Attribute Summary collapse
-
#bin_path ⇒ Object
readonly
Returns the value of attribute bin_path.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(bin_path: nil, port: nil) ⇒ Harness
constructor
A new instance of Harness.
- #running? ⇒ Boolean
- #start! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(bin_path: nil, port: nil) ⇒ Harness
Returns a new instance of Harness.
10 11 12 13 14 |
# File 'lib/antigravity/harness.rb', line 10 def initialize(bin_path: nil, port: nil) @bin_path = bin_path || Antigravity.config.harness_path @port = port || find_free_port @pid = nil end |
Instance Attribute Details
#bin_path ⇒ Object (readonly)
Returns the value of attribute bin_path.
8 9 10 |
# File 'lib/antigravity/harness.rb', line 8 def bin_path @bin_path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
8 9 10 |
# File 'lib/antigravity/harness.rb', line 8 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/antigravity/harness.rb', line 8 def port @port end |
Instance Method Details
#running? ⇒ Boolean
40 41 42 |
# File 'lib/antigravity/harness.rb', line 40 def running? !@pid.nil? end |
#start! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/antigravity/harness.rb', line 16 def start! return if running? unless File.exist?(@bin_path) && File.executable?(@bin_path) # Mock mode or fallback if localharness executable is missing warn "[Antigravity::Harness] Warning: localharness binary not found at #{@bin_path}. Running in mock mode." return true end cmd = "#{@bin_path} --port=#{@port}" @stdin, @stdout, @stderr, wait_thr = Open3.popen3(cmd) @pid = wait_thr.pid at_exit { stop! } true end |
#stop! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/antigravity/harness.rb', line 33 def stop! return unless running? Process.kill("TERM", @pid) rescue nil @pid = nil end |