rapns 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rapns/daemon/feeder.rb +3 -6
- data/lib/rapns/daemon.rb +5 -2
- data/lib/rapns/version.rb +1 -1
- data/spec/rapns/daemon_spec.rb +7 -0
- metadata +1 -1
data/lib/rapns/daemon/feeder.rb
CHANGED
@@ -2,13 +2,10 @@ module Rapns
|
|
2
2
|
module Daemon
|
3
3
|
class Feeder
|
4
4
|
def self.start
|
5
|
-
|
6
|
-
|
7
|
-
|
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
data/spec/rapns/daemon_spec.rb
CHANGED
@@ -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)
|