coney_island 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/coney_island/version.rb +1 -1
- data/lib/coney_island/worker.rb +25 -3
- data/test/dummy/log/test.log +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d091ef6d980cadba61712e9b2a597cae791df0e4
|
4
|
+
data.tar.gz: f6a0f197c6c441ebed031fae08ae35c6069a9129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2176dd0cc32b96638bb949fe6572356fe4fdaa91a3bfc81dcf988f771445c2bed0cfa2ec7a6aaa6263dbb89923df3bdd74108455594c15c9a7d6254616032f3c
|
7
|
+
data.tar.gz: 50ffdea1c5394ee0738dd08b463b41022646e0317c6e0d4f43f6045de6020b43fc0a36cc930e33b464d1ee6ee464fb0b188750e6706aeb9e4d45c3cecb406b8b
|
data/lib/coney_island/version.rb
CHANGED
data/lib/coney_island/worker.rb
CHANGED
@@ -21,6 +21,10 @@ module ConeyIsland
|
|
21
21
|
@job_attempts ||= {}
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.clear_job_attempts
|
25
|
+
@job_attempts = {}
|
26
|
+
end
|
27
|
+
|
24
28
|
def self.initialize_background
|
25
29
|
ENV['NEW_RELIC_AGENT_ENABLED'] = 'false'
|
26
30
|
ENV['NEWRELIC_ENABLE'] = 'false'
|
@@ -88,10 +92,11 @@ module ConeyIsland
|
|
88
92
|
self.shutdown('TERM')
|
89
93
|
end
|
90
94
|
|
91
|
-
AMQP.connect(self.amqp_parameters) do |connection|
|
95
|
+
AMQP.connect(self.amqp_parameters.merge(heartbeat: 15)) do |connection|
|
92
96
|
connection.on_tcp_connection_loss do |connection, settings|
|
93
|
-
#
|
94
|
-
|
97
|
+
# since we lost the connection, rabbitMQ will resend all jobs we didn't finish
|
98
|
+
# so drop them and restart
|
99
|
+
self.abandon_and_shutdown
|
95
100
|
end
|
96
101
|
self.log.info("Connected to AMQP broker. Running #{AMQP::VERSION}")
|
97
102
|
@channel = AMQP::Channel.new(connection)
|
@@ -101,6 +106,7 @@ module ConeyIsland
|
|
101
106
|
heartbeat_exchange = self.channel.fanout('coney_island_heartbeat')
|
102
107
|
EventMachine.add_periodic_timer(15) do
|
103
108
|
heartbeat_exchange.publish({:instance_name => @ticket})
|
109
|
+
self.handle_missing_children
|
104
110
|
end
|
105
111
|
|
106
112
|
self.channel.prefetch @prefetch_count
|
@@ -205,6 +211,22 @@ module ConeyIsland
|
|
205
211
|
self.job_attempts.delete job_id
|
206
212
|
end
|
207
213
|
|
214
|
+
def self.handle_missing_children
|
215
|
+
@child_pids.each do |child_pid|
|
216
|
+
begin
|
217
|
+
Process.kill 0, child_pid
|
218
|
+
rescue Errno::ESRCH => e
|
219
|
+
@child_pids.push Process.spawn("bundle exec coney_island #{@ticket}")
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def self.abandon_and_shutdown
|
225
|
+
self.log.info("Lost RabbitMQ connection, abandoning current jobs and restarting")
|
226
|
+
self.clear_job_attempts
|
227
|
+
self.shutdown('TERM')
|
228
|
+
end
|
229
|
+
|
208
230
|
def self.shutdown(signal)
|
209
231
|
shutdown_time = Time.now
|
210
232
|
@child_pids.each do |child_pid|
|
data/test/dummy/log/test.log
CHANGED
@@ -6,3 +6,7 @@ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
|
6
6
|
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
7
7
|
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
8
8
|
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
9
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
10
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
11
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
12
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|