class Rookout::RookoutSingleton

Attributes

services[R]

Public Class Methods

new() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 16
def initialize
  check_version_supported

  @output = ComWs::Output.new

  @services_started = false
  @services = TriggerServices.new

  @aug_manager = Augs::AugsManager.new @services, @output

  @agent_com = nil
end

Public Instance Methods

connect(token: nil, host: nil, port: nil, proxy: nil, labels: [], async_start: false, fork: false) click to toggle source
# File lib/rookout/rookout_singleton.rb, line 43
def connect token: nil, host: nil, port: nil, proxy: nil, labels: [], async_start: false, fork: false
  raise Exceptions::RookInterfaceException, "Multiple connection attempts not supported!" unless @agent_com.nil?

  if fork
    require_relative "atfork"
    Rookout::ForkManager.instance.activate!
  end

  start_trigger_services

  Logger.instance.debug "Initiating AgentCom-\t#{host}:#{port}"

  @agent_com = ComWs::AgentComWs.new @output, host, port, proxy, token, labels
  @output.agent_com = @agent_com
  @command_handler = ComWs::CommandHandler.new @agent_com, @aug_manager

  @agent_com.connect
  return if async_start

  @agent_com.wait_for_ready
end
flush() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 65
def flush
  @output.flush_messages if !@output.nil && !@agent_com.nil?
end
post_fork_clean() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 69
def post_fork_clean
  @agent_com.stop
  @agent_com = nil

  @command_handler = nil

  # We don't disable services because we will lose all loaded scripts
  @services.clear_augs
end
start_trigger_services() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 29
def start_trigger_services
  return if @services_started

  @services.start
  @services_started = true
end
stop_trigger_services() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 36
def stop_trigger_services
  return unless @services_started

  @services.close
  @services_started = false
end

Private Instance Methods

check_version_supported() click to toggle source
# File lib/rookout/rookout_singleton.rb, line 83
def check_version_supported
  raise Exceptions:: RookVersionNotSupported.new("platform", RUBY_ENGINE) unless RUBY_ENGINE == "ruby"
  raise Exceptions::RookVersionNotSupported.new("version", RUBY_VERSION) unless
      RUBY_VERSION.start_with?("2.7") || RUBY_VERSION.start_with?("2.6")
end