coney_island 0.7.5 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f039e0c6dcd7965fd53e9563264440a0f2cfbd51
4
- data.tar.gz: 2769bb8e3e684f0b0d3b5b0cce0fb2033dd1c116
3
+ metadata.gz: d091ef6d980cadba61712e9b2a597cae791df0e4
4
+ data.tar.gz: f6a0f197c6c441ebed031fae08ae35c6069a9129
5
5
  SHA512:
6
- metadata.gz: b89c9a90de86274b2c006e95827de7e7c1909e02a5fae9620b2895d98bcdc69b0b8ce595dc3dd74acd5d1793e0f7a12cad28f92b41c7fb0c9b8c3bc26434ee94
7
- data.tar.gz: 2cbb3dc9b4dba357951481935a13921c4b3e68d5c6b8d853f8a68140e023734996b0eccb832a45a52358f71097e95f80a8039483615e4be9b86c419f19633268
6
+ metadata.gz: 2176dd0cc32b96638bb949fe6572356fe4fdaa91a3bfc81dcf988f771445c2bed0cfa2ec7a6aaa6263dbb89923df3bdd74108455594c15c9a7d6254616032f3c
7
+ data.tar.gz: 50ffdea1c5394ee0738dd08b463b41022646e0317c6e0d4f43f6045de6020b43fc0a36cc930e33b464d1ee6ee464fb0b188750e6706aeb9e4d45c3cecb406b8b
@@ -1,3 +1,3 @@
1
1
  module ConeyIsland
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.7"
3
3
  end
@@ -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
- # reconnect in 10 seconds, without enforcement
94
- connection.reconnect(false, 10)
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|
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coney_island
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut