Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added some sync messages to make troubleshooting easier #60

Closed
wants to merge 1 commit into from

2 participants

@dei79

I added some log messages in Apprunner#sync to make the troubleshooting via log file easier

@travisbot

This pull request fails (merged 5fac1c7e into 7dbbecf).

@dei79 dei79 Added RemoteSignal to notify the daemon on an in app level. Use the f…
…ollowig call

for starting a hot update

Rapns::RemoteSignal.push :key => :hup
dc21e48
@travisbot

This pull request fails (merged dc21e48 into 7dbbecf).

@dei79 dei79 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2012
  1. @dei79

    Added RemoteSignal to notify the daemon on an in app level. Use the f…

    dei79 authored
    …ollowig call
    
    for starting a hot update
    
    Rapns::RemoteSignal.push :key => :hup
This page is out of date. Refresh to see the latest.
View
3  .gitignore
@@ -5,4 +5,5 @@ pkg/*
coverage/
.rbx/
spec/acceptance/fixtures
-.rbenv-version
+.rbenv-version
+.idea
View
1  lib/generators/rapns_generator.rb
@@ -15,6 +15,7 @@ def copy_migration
add_rapns_migration('add_alert_is_json_to_rapns_notifications')
add_rapns_migration('add_app_to_rapns')
add_rapns_migration('create_rapns_apps')
+ add_rapns_migration('create_rapns_remote_signals')
end
protected
View
12 lib/generators/templates/create_rapns_remote_signals.rb
@@ -0,0 +1,12 @@
+class CreateRapnsRemoteSignals < ActiveRecord::Migration
+ def self.up
+ create_table :rapns_remote_signals do |t|
+ t.string :key, :null => false
+ t.text :payload, :null => true
+ end
+ end
+
+ def self.down
+ drop_table :rapns_remote_signals
+ end
+end
View
1  lib/rapns.rb
@@ -7,3 +7,4 @@
require 'rapns/notification'
require 'rapns/feedback'
require 'rapns/app'
+require 'rapns/remote_signal'
View
19 lib/rapns/daemon/feeder.rb
@@ -11,6 +11,7 @@ def self.name
def self.start(poll)
loop do
break if @stop
+ process_pending_signals
enqueue_notifications
interruptible_sleep poll
end
@@ -36,6 +37,24 @@ def self.enqueue_notifications
Rapns::Daemon.logger.error(e)
end
end
+
+ def self.process_pending_signals
+ begin
+ with_database_reconnect_and_retry do
+ loop do
+ signal = Rapns::RemoteSignal.pop
+ break if signal.nil?
+
+ case signal.key.to_sym
+ when :hup then Rapns::Daemon::AppRunner.sync
+ else Rapns::Daemon.logger.info("[RemoteSignal] Unknown singal received #{signal.key} (ignoring) ")
+ end
+ end
+ end
+ rescue StandardError => e
+ Rapns::Daemon.logger.error(e)
+ end
+ end
end
end
end
View
27 lib/rapns/remote_signal.rb
@@ -0,0 +1,27 @@
+module Rapns
+ class RemoteSignal < ActiveRecord::Base
+ self.table_name = 'rapns_remote_signals'
+
+ validates :key, :presence => true
+
+ # returns the next signal
+ def self.pop
+
+ signal = nil
+
+ transaction do
+ signal = Rapns::RemoteSignal.first
+ signal.destroy unless signal.nil?
+ end
+
+ signal
+ end
+
+ def self.push(options = {})
+ remoteSignal = Rapns::RemoteSignal.new()
+ remoteSignal.key = options[:key]
+ remoteSignal.payload = options[:payload] if options[:payload]
+ remoteSignal.save!
+ end
+ end
+end
Something went wrong with that request. Please try again.