Feature: Notify / wake feeder via UDP socket #164

merged 1 commit into from Sep 16, 2013


None yet

2 participants


This feature adds a class Rapns::Notifier which allows a web or other process to wake the Rapns daemon from sleep to send a notification immediately. This allows a much longer sleep time for lower polling / log activity.

Example notifier usage:

require 'rapns/notifier'
notifier = Rapns::Notifier.new(udp_host, udp_port)
notifier.notify # => wakes the daemon.

This is left as a separate require because it isn't used in the daemon, and can be used externally.


Nice! I'll likely make some changes to the API and how this is configured, but I like the idea, so going to merge. Thanks :)

@ileitch ileitch merged commit 1feb432 into ileitch:master Sep 16, 2013

1 check failed

Details default The Travis CI build failed

FYI, some thoughts on API changes I may make:

Use Rapns.configure:

Rapns.configure do |config|
  config.wakeup.host = ...
  config.wakeup.port = ...

Then, perhaps:

Rapns.wakeup_daemon # or just wakeup

I'll probably remove all references to udp in the user-facing code, as it's an implementation detail.


Great. Rapns.wakeup will be much nicer to use, my current line of code is:

Rapns::Notifier.new(Rapns.config.udp_wake_host, Rapns.config.udp_wake_port).notify rescue nil

I agree that UDP should be removed from the name. Good thinking. config could be more like:

Rapns.config.wake = { :host => '', :port => 1234 }



We may also need a connect address since the binding socket may want to bind on '' but the notifier will need an explicit address to connect to.

A rails app may be running on a separate machine, for example. So rapns could easily bind to '', but the rails instance would need to know the IP address.

How about:

Rapns.config.wakeup = { :bind => '', :connect => '', :port => 1234 }


@mattconnolly mattconnolly deleted the mattconnolly:udp-wake branch Sep 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment