class QPush::Server::Heartbeat

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

Public Class Methods

new() click to toggle source
# File lib/qpush/server/heartbeat.rb, line 8
def initialize
  @done = false
end

Public Instance Methods

shutdown() click to toggle source

Shutsdown our heartbeat process.

# File lib/qpush/server/heartbeat.rb, line 23
def shutdown
  @done = true
end
start() click to toggle source

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

# File lib/qpush/server/heartbeat.rb, line 14
def start
  until @done
    Server.redis { |c| c.setex(Server.keys[:heart], 30, true) }
    sleep 15
  end
end