Class: EatMySoul::Manager
- Inherits:
-
Object
- Object
- EatMySoul::Manager
- Includes:
- Singleton
- Defined in:
- lib/eatmysoul.rb
Instance Attribute Summary collapse
-
#active_connection ⇒ Object
Returns the value of attribute active_connection.
-
#monitor_timer ⇒ Object
Returns the value of attribute monitor_timer.
Instance Method Summary collapse
Instance Attribute Details
#active_connection ⇒ Object
Returns the value of attribute active_connection.
228 229 230 |
# File 'lib/eatmysoul.rb', line 228 def active_connection @active_connection end |
#monitor_timer ⇒ Object
Returns the value of attribute monitor_timer.
228 229 230 |
# File 'lib/eatmysoul.rb', line 228 def monitor_timer @monitor_timer end |
Instance Method Details
#connect_loop(o) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/eatmysoul.rb', line 237 def connect_loop(o) while true do sleep_time = 0 begin self.run(o) rescue => e o.logger.fatal "Rescued from exception #{e}" o.logger.debug e.backtrace.join "\n" end sleep sleep_time sleep_time = sleep_time + 5 if sleep_time < 120 end end |
#monitor(o) ⇒ Object
253 254 255 256 257 258 259 260 261 |
# File 'lib/eatmysoul.rb', line 253 def monitor(o) if active_connection o.logger.debug "Checking for connection inactivity" if (Time.now - active_connection.last_ping) > 650 o.logger.warn "Connection seems inactive, restarting ..." active_connection.close_connection end end end |
#run(o) ⇒ Object
230 231 232 233 234 235 |
# File 'lib/eatmysoul.rb', line 230 def run(o) EM.run do monitor_timer = EM::add_periodic_timer(1) { monitor o } unless monitor_timer EM.connect o.server, o.port, Netsoul, o end end |