Class: TrueAutomation::Client
- Inherits:
-
Object
- Object
- TrueAutomation::Client
- Defined in:
- lib/true_automation/client.rb
Instance Method Summary collapse
Instance Method Details
#start(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/true_automation/client.rb', line 9 def start() @port = [:port] || 9515 @executable = ENV['TRUEAUTOMATION_EXEC'] || 'trueautomation' if find_executable(@executable).nil? raise "`#{@executable}` not found. Can not find TrueAutomation.IO client" end trueautomation_version = `#{@executable} --version` puts "TrueAutomation.IO client #{trueautomation_version.strip}" Dir.mkdir('log') unless File.exist?('log') logfile = "log/trueautomation-#{Time.now.strftime('%Y%m%dT%H%M%S')}.log" @pid = spawn("#{@executable} --log-file #{logfile} --port #{@port}") puts "Started TrueAutomation.IO client with pid #{@pid} listening to port #{@port}" @pid end |
#stop ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/true_automation/client.rb', line 30 def stop if @pid puts "Stopping TrueAutomation.IO Client with pid #{@pid}" if Gem.win_platform? system("taskkill /pid #{@pid}") else Process.kill('TERM', @pid) end @pid = nil end end |
#wait_until_start ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/true_automation/client.rb', line 44 def wait_until_start counter = 0 loop do break if check_connection or counter >= 10 counter += 1 sleep 2 end end |