Class: Rookout::RookoutSingleton
- Inherits:
-
Object
- Object
- Rookout::RookoutSingleton
- Includes:
- Singleton
- Defined in:
- lib/rookout/rookout_singleton.rb
Instance Attribute Summary collapse
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #connect(token: nil, host: nil, port: nil, proxy: nil, labels: {}, async_start: false, fork: false, throw_errors: false) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ RookoutSingleton
constructor
A new instance of RookoutSingleton.
- #post_fork_clean ⇒ Object
- #start_trigger_services ⇒ Object
- #stop_trigger_services ⇒ Object
Constructor Details
#initialize ⇒ RookoutSingleton
Returns a new instance of RookoutSingleton.
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
#services ⇒ Object (readonly)
Returns the value of attribute services.
80 81 82 |
# File 'lib/rookout/rookout_singleton.rb', line 80 def services @services end |
Instance Method Details
#connect(token: nil, host: nil, port: nil, proxy: nil, labels: {}, async_start: false, fork: false, throw_errors: false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rookout/rookout_singleton.rb', line 43 def connect token: nil, host: nil, port: nil, proxy: nil, labels: {}, async_start: false, fork: false, throw_errors: 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, !throw_errors @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 ⇒ Object
66 67 68 |
# File 'lib/rookout/rookout_singleton.rb', line 66 def flush @output. if !@output.nil && !@agent_com.nil? end |
#post_fork_clean ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/rookout/rookout_singleton.rb', line 70 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 ⇒ Object
29 30 31 32 33 34 |
# 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 ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rookout/rookout_singleton.rb', line 36 def stop_trigger_services return unless @services_started @services.close @services_started = false end |