rapns 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,13 +2,10 @@ module Rapns
2
2
  module Daemon
3
3
  class Feeder
4
4
  def self.start
5
- @thread = Thread.new do
6
- loop do
7
- break if @stop
8
- enqueue_notifications
9
- end
5
+ loop do
6
+ break if @stop
7
+ enqueue_notifications
10
8
  end
11
- @thread.join
12
9
  end
13
10
 
14
11
  def self.enqueue_notifications
data/lib/rapns/daemon.rb CHANGED
@@ -32,14 +32,17 @@ module Rapns
32
32
 
33
33
  self.delivery_queue = DeliveryQueue.new
34
34
 
35
+ unless foreground?
36
+ daemonize
37
+ ActiveRecord::Base.establish_connection
38
+ end
39
+
35
40
  self.delivery_handler_pool = DeliveryHandlerPool.new(configuration.connections)
36
41
  delivery_handler_pool.populate
37
42
 
38
43
  self.connection_pool = ConnectionPool.new(configuration.connections)
39
44
  connection_pool.populate
40
45
 
41
- daemonize unless foreground?
42
-
43
46
  Feeder.start
44
47
  end
45
48
 
data/lib/rapns/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rapns
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -76,10 +76,17 @@ describe Rapns::Daemon, "when starting" do
76
76
  end
77
77
 
78
78
  it "should fork a child process if the foreground option is false" do
79
+ ActiveRecord::Base.stub(:establish_connection)
79
80
  Rapns::Daemon.should_receive(:daemonize)
80
81
  Rapns::Daemon.start("development", false)
81
82
  end
82
83
 
84
+ it "should re-establish the connection to the database after being forked" do
85
+ ActiveRecord::Base.should_receive(:establish_connection)
86
+ Rapns::Daemon.stub(:daemonize)
87
+ Rapns::Daemon.start("development", false)
88
+ end
89
+
83
90
  it "should not fork a child process if the foreground option is true" do
84
91
  Rapns::Daemon.should_not_receive(:daemonize)
85
92
  Rapns::Daemon.start("development", true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: