coney_island 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coney_island/railtie.rb +3 -1
- data/lib/coney_island/version.rb +1 -1
- data/lib/coney_island/worker.rb +27 -27
- data/test/dummy/log/test.log +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6e16e85747e1d7eb7ca008b0b193d0b7bb5968
|
4
|
+
data.tar.gz: 26c71402914d4a3947270aed653da903955ce0b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8798aa23ab52a69563f618cbe330279389635a6abe0432b95a599913610cf05a701387fa6142467bf4b5b9f6497f8c3e3bba40b7fbef08f5650a09f5b9cf8502
|
7
|
+
data.tar.gz: e76ed3ee358c56c542fc4ce909aed4e0fc0f849bdb6eaccd5044b11d987c619f01f35446014f0b1c02c10243191894c174985a35dc917ca860475f4bd85bb94f
|
data/lib/coney_island/railtie.rb
CHANGED
@@ -2,7 +2,9 @@ require 'coney_island/coney_island_adapter'
|
|
2
2
|
module ConeyIsland
|
3
3
|
class Railtie < Rails::Railtie
|
4
4
|
initializer "coney_island.coney_island_adapter" do
|
5
|
-
|
5
|
+
if defined? ActiveJob
|
6
|
+
ActiveJob::QueueAdapters.send :autoload, :ConeyIslandAdapter
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
data/lib/coney_island/version.rb
CHANGED
data/lib/coney_island/worker.rb
CHANGED
@@ -78,19 +78,19 @@ module ConeyIsland
|
|
78
78
|
defined?(ActiveRecord::Base) and
|
79
79
|
ActiveRecord::Base.establish_connection
|
80
80
|
|
81
|
-
|
82
|
-
EventMachine.run do
|
81
|
+
EventMachine.run do
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
Signal.trap('INT') do
|
84
|
+
self.shutdown('INT')
|
85
|
+
end
|
86
|
+
Signal.trap('TERM') do
|
87
|
+
self.shutdown('TERM')
|
88
|
+
end
|
90
89
|
|
90
|
+
begin
|
91
91
|
AMQP.connect(self.amqp_parameters) do |connection|
|
92
92
|
self.log.info("Connected to AMQP broker. Running #{AMQP::VERSION}")
|
93
|
-
@channel
|
93
|
+
@channel = AMQP::Channel.new(connection)
|
94
94
|
@exchange = @channel.topic('coney_island')
|
95
95
|
|
96
96
|
#send a heartbeat every 15 seconds to avoid aggresive network configurations that close quiet connections
|
@@ -106,22 +106,22 @@ module ConeyIsland
|
|
106
106
|
self.handle_incoming_message(metadata,payload)
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
ConeyIsland.tcp_connection_retries
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
109
|
+
rescue AMQP::TCPConnectionFailed => e
|
110
|
+
ConeyIsland.tcp_connection_retries ||= 0
|
111
|
+
ConeyIsland.tcp_connection_retries += 1
|
112
|
+
if ConeyIsland.tcp_connection_retries >= ConeyIsland.tcp_connection_retry_limit
|
113
|
+
message = "Failed to connect to RabbitMQ #{ConeyIsland.tcp_connection_retry_limit} times, bailing out"
|
114
|
+
self.log.error(message)
|
115
|
+
ConeyIsland.poke_the_badger(e, {
|
116
|
+
code_source: 'ConeyIsland::Worker.start',
|
117
|
+
reason: message}
|
118
|
+
)
|
119
|
+
else
|
120
|
+
message = "Failed to connecto to RabbitMQ Attempt ##{ConeyIsland.tcp_connection_retries} time(s), trying again in #{ConeyIsland.tcp_connection_retry_interval} seconds..."
|
121
|
+
self.log.error(message)
|
122
|
+
sleep(10)
|
123
|
+
retry
|
124
|
+
end
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -141,7 +141,7 @@ module ConeyIsland
|
|
141
141
|
end
|
142
142
|
rescue Timeout::Error => e
|
143
143
|
ConeyIsland.poke_the_badger(e, {code_source: 'ConeyIsland', job_payload: args, reason: 'timeout in subscribe code before calling job method'})
|
144
|
-
rescue
|
144
|
+
rescue StandardError => e
|
145
145
|
ConeyIsland.poke_the_badger(e, {code_source: 'ConeyIsland', job_payload: args})
|
146
146
|
self.log.error("ConeyIsland code error, not application code:\n#{e.inspect}\nARGS: #{args}")
|
147
147
|
end
|
@@ -166,7 +166,7 @@ module ConeyIsland
|
|
166
166
|
self.handle_job(metadata,args,job_id)
|
167
167
|
end
|
168
168
|
end
|
169
|
-
rescue
|
169
|
+
rescue StandardError => e
|
170
170
|
ConeyIsland.poke_the_badger(e, {work_queue: @ticket, job_payload: args})
|
171
171
|
self.log.error("Error executing #{args['klass']}##{args['method_name']} #{job_id} for id #{args['instance_id']} with args #{args}:")
|
172
172
|
self.log.error(e.message)
|
data/test/dummy/log/test.log
CHANGED
@@ -1,2 +1,4 @@
|
|
1
1
|
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
2
2
|
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
3
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
4
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
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.
|
4
|
+
version: '0.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|