rabbit_jobs 0.2.0.pre3 → 0.2.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rabbit_jobs/job.rb +4 -3
- data/lib/rabbit_jobs/util.rb +28 -13
- data/lib/rabbit_jobs/version.rb +3 -1
- metadata +8 -8
data/lib/rabbit_jobs/job.rb
CHANGED
@@ -22,7 +22,8 @@ module RabbitJobs::Job
|
|
22
22
|
self.class.perform(*params)
|
23
23
|
rescue
|
24
24
|
RJ.logger.warn(self.inspect)
|
25
|
-
RJ.logger.warn
|
25
|
+
RJ.logger.warn $!.message
|
26
|
+
RJ.logger.warn RJ::Util.cleanup_backtrace($!.backtrace).join("\n")
|
26
27
|
run_on_error_hooks($!)
|
27
28
|
RabbitJobs::ErrorMailer.report_error(self, $!)
|
28
29
|
end
|
@@ -100,8 +101,8 @@ module RabbitJobs::Job
|
|
100
101
|
:not_found
|
101
102
|
rescue
|
102
103
|
RJ.logger.error "JOB INIT ERROR at #{Time.now.to_s}:"
|
103
|
-
RJ.logger.
|
104
|
-
RJ.logger.
|
104
|
+
RJ.logger.warn $!.message
|
105
|
+
RJ.logger.warn RJ::Util.cleanup_backtrace($!.backtrace).join("\n")
|
105
106
|
RJ.logger.error "message: #{payload.inspect}"
|
106
107
|
nil
|
107
108
|
end
|
data/lib/rabbit_jobs/util.rb
CHANGED
@@ -1,21 +1,36 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
module RabbitJobs
|
4
|
-
|
5
|
-
|
6
|
-
if File.exists?(pidfile)
|
7
|
-
pid = File.read(pidfile).to_i
|
8
|
-
begin
|
9
|
-
Process.kill(0, pid)
|
10
|
-
RJ.logger.info "Killing old rabbit_jobs process ##{pid}"
|
11
|
-
Process.kill("TERM", pid)
|
3
|
+
module RabbitJobs
|
4
|
+
class Util
|
5
|
+
class << self
|
12
6
|
|
13
|
-
|
14
|
-
|
7
|
+
# clean old worker process
|
8
|
+
def check_pidfile(pidfile)
|
9
|
+
if File.exists?(pidfile)
|
10
|
+
pid = File.read(pidfile).to_i
|
11
|
+
begin
|
12
|
+
Process.kill(0, pid)
|
13
|
+
RJ.logger.info "Killing old rabbit_jobs process ##{pid}"
|
14
|
+
Process.kill("TERM", pid)
|
15
|
+
|
16
|
+
while Process.kill(0, pid)
|
17
|
+
sleep(0.5)
|
18
|
+
end
|
19
|
+
rescue
|
20
|
+
File.delete(pidfile) if File.exists?(pidfile)
|
21
|
+
end
|
15
22
|
end
|
16
|
-
rescue
|
17
|
-
File.delete(pidfile) if File.exists?(pidfile)
|
18
23
|
end
|
24
|
+
|
25
|
+
def cleanup_backtrace(trace_lines)
|
26
|
+
if defined?(Rails) && Rails.respond_to?(:root)
|
27
|
+
rails_root_path = Rails.root.to_s
|
28
|
+
trace_lines.dup.keep_if { |l| l[rails_root_path] }
|
29
|
+
else
|
30
|
+
trace_lines
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
19
34
|
end
|
20
35
|
end
|
21
36
|
end
|
data/lib/rabbit_jobs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.pre4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-11-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
16
|
-
requirement: &
|
16
|
+
requirement: &16470020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16470020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &16499220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16499220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rufus-scheduler
|
38
|
-
requirement: &
|
38
|
+
requirement: &16496980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *16496980
|
47
47
|
description: Background jobs on RabbitMQ
|
48
48
|
email:
|
49
49
|
- lazureykis@gmail.com
|
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
segments:
|
100
100
|
- 0
|
101
|
-
hash:
|
101
|
+
hash: 2644135263764461757
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
none: false
|
104
104
|
requirements:
|