Module: TingYun::Agent::InstanceMethods::StartWorkerThread
- Included in:
- TingYun::Agent::InstanceMethods
- Defined in:
- lib/ting_yun/agent/instance_methods/start_worker_thread.rb
Instance Method Summary collapse
- #create_and_run_event_loop ⇒ Object
-
#deferred_work!(connection_options) ⇒ Object
This is the method that is run in a new thread in order to background the harvesting and sending of data during the normal operation of the agent.
- #start_worker_thread(connection_options = {}) ⇒ Object
Instance Method Details
#create_and_run_event_loop ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ting_yun/agent/instance_methods/start_worker_thread.rb', line 38 def create_and_run_event_loop @event_loop = TingYun::Agent::Event::EventLoop.new @event_loop.on(:report_data) do transmit_data end @event_loop.fire_every(Agent.config[:data_report_period], :report_data) @event_loop.on(:create_new_logfile) do TingYun::Logger::CreateLoggerHelper.create_new_logfile end @event_loop.fire_every(TingYun::Agent.config[:agent_log_file_check_days]*60*60*24, :create_new_logfile) @event_loop.run end |
#deferred_work!(connection_options) ⇒ Object
This is the method that is run in a new thread in order to background the harvesting and sending of data during the normal operation of the agent.
Takes connection options that determine how we should connect to the server, and loops endlessly - typically we never return from this method unless we’re shutting down the agent
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ting_yun/agent/instance_methods/start_worker_thread.rb', line 25 def deferred_work!() catch_errors do TingYun::Agent.disable_all_tracing do connect!() if connected? create_and_run_event_loop else TingYun::Agent.logger.debug "No connection. Worker thread ending." end end end end |
#start_worker_thread(connection_options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/ting_yun/agent/instance_methods/start_worker_thread.rb', line 10 def start_worker_thread(={}) TingYun::Agent.logger.debug "Creating Ruby Agent worker thread." @worker_thread = TingYun::Agent::Threading::AgentThread.create('Worker Loop') do deferred_work!() end end |