Class: QPush::Server::Heartbeat

Inherits:
Object
  • Object
show all
Defined in:
lib/qpush/server/heartbeat.rb

Overview

The Heartbeat worker periodically updates the heart namespace. The key is set with an expiry. This helps to indicate if the QPush server is currently active.

Instance Method Summary collapse

Constructor Details

#initializeHeartbeat

Returns a new instance of Heartbeat.



8
9
10
# File 'lib/qpush/server/heartbeat.rb', line 8

def initialize
  @done = false
end

Instance Method Details

#shutdownObject

Shutsdown our heartbeat process.



23
24
25
# File 'lib/qpush/server/heartbeat.rb', line 23

def shutdown
  @done = true
end

#startObject

Starts our perform process. This will run until instructed to stop.



14
15
16
17
18
19
# File 'lib/qpush/server/heartbeat.rb', line 14

def start
  until @done
    QPush.redis.with { |c| c.setex(QPush.keys.heart, 30, true) }
    sleep 15
  end
end