Class: Superbot::CLI::TeleportCommand

Inherits:
Clamp::Command
  • Object
show all
Includes:
Superbot::Cloud::Validations, Validations
Defined in:
lib/superbot/cli/teleport_command.rb

Instance Method Summary collapse

Methods included from Validations

#validates_browser_type, #validates_project_path

Instance Method Details

#close_teleportObject



48
49
50
51
# File 'lib/superbot/cli/teleport_command.rb', line 48

def close_teleport
  @chromedriver&.kill
  @web&.quit!
end

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/superbot/cli/teleport_command.rb', line 16

def execute
   unless browser == 'local'

  @web = Superbot::Web.new(webdriver_type: browser, region: region)
  @web.run_async_after_running!

  @chromedriver = Kommando.run_async 'chromedriver --silent --port=9515' if browser == 'local'

  puts "", "🤖 Teleport is open ☁️ "
  puts "", "Configure your webdriver to http://localhost:4567/wd/hub"
  puts "", "Press [control+c] to close teleport"

  handle_keyboard_interrupt
ensure
  close_teleport
end

#handle_keyboard_interruptObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/superbot/cli/teleport_command.rb', line 33

def handle_keyboard_interrupt
  @interrupted = false

  trap "SIGINT" do
    puts
    puts "Command killed by keyboard interrupt"
    @interrupted = true
    exit 130
  end

  loop do
    break if @interrupted
  end
end