Module: Tracebin::Agent
- Defined in:
- lib/tracebin/agent.rb
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.storage ⇒ Object
Returns the value of attribute storage.
Class Method Summary collapse
- .child_process_started? ⇒ Boolean
- .configure {|config| ... } ⇒ Object
- .init_logger ⇒ Object
- .init_storage ⇒ Object
- .log_level ⇒ Object
- .parent_process_started? ⇒ Boolean
- .reset ⇒ Object
- .start_child_process ⇒ Object
- .start_parent_process ⇒ Object
- .stop_child_processes ⇒ Object
- .stop_parent_process ⇒ Object
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
13 14 15 |
# File 'lib/tracebin/agent.rb', line 13 def config @config end |
.logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/tracebin/agent.rb', line 13 def logger @logger end |
.storage ⇒ Object
Returns the value of attribute storage.
13 14 15 |
# File 'lib/tracebin/agent.rb', line 13 def storage @storage end |
Class Method Details
.child_process_started? ⇒ Boolean
83 84 85 |
# File 'lib/tracebin/agent.rb', line 83 def child_process_started? @child_process_started end |
.configure {|config| ... } ⇒ Object
126 127 128 |
# File 'lib/tracebin/agent.rb', line 126 def self.configure yield config end |
.init_logger ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tracebin/agent.rb', line 87 def init_logger if defined? ::Rails @logger = ::Rails.logger else @logger ||= Logger.new(STDOUT) @logger.level = log_level end @logger end |
.init_storage ⇒ Object
109 110 111 |
# File 'lib/tracebin/agent.rb', line 109 def init_storage @storage = ::Tracebin::Storage.new end |
.log_level ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/tracebin/agent.rb', line 98 def log_level case config.log_level.downcase when 'debug' then Logger::DEBUG when 'info' then Logger::INFO when 'warn' then Logger::WARN when 'error' then Logger::ERROR when 'fatal' then Logger::FATAL else Logger::INFO end end |
.parent_process_started? ⇒ Boolean
79 80 81 |
# File 'lib/tracebin/agent.rb', line 79 def parent_process_started? @parent_process_started end |
.reset ⇒ Object
122 123 124 |
# File 'lib/tracebin/agent.rb', line 122 def self.reset @config = Config.new end |
.start_child_process ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tracebin/agent.rb', line 34 def start_child_process return if child_process_started? || !config.enabled logger.info "TRACEBIN: Starting Tracebin child process..." init_storage @child_process_reporter = Reporter.new @child_process_reporter.start! @child_process_started = true logger.info "TRACEBIN: Tracebin child process started!" rescue => e logger.info "TRACEBIN: Error occurred while trying to start child process: #{e.message}" end |
.start_parent_process ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tracebin/agent.rb', line 15 def start_parent_process return if parent_process_started? || !config.enabled logger.info "TRACEBIN: Starting Tracebin parent process..." init_storage @subscribers = Subscribers.new @health_monitor = HealthMonitor.start @worker_process_monitor = WorkerProcessMonitor.start @parent_process_reporter = Reporter.new @parent_process_reporter.start! @parent_process_started = true logger.info "TRACEBIN: Tracebin parent process started!" rescue => e logger.info "TRACEBIN: Error occurred while trying to start parent process: #{e.message}" end |
.stop_child_processes ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tracebin/agent.rb', line 65 def stop_child_processes return unless child_process_started? logger.info "TRACEBIN: Shutting down child process..." @child_process_reporter.stop! storage.unload @child_process_started = false logger.info "TRACEBIN: Child process stopped!" end |
.stop_parent_process ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/tracebin/agent.rb', line 49 def stop_parent_process return unless parent_process_started? logger.info "TRACEBIN: Shutting down parent process..." @health_monitor.stop! @worker_process_monitor.stop! @parent_process_reporter.stop! storage.unload @parent_process_started = false logger.info "TRACEBIN: Parent process stopped!" end |