rabbit_jobs 0.1.8.2 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,10 +72,9 @@ module RabbitJobs
72
72
  @data[name]
73
73
  end
74
74
 
75
- def mail_errors_to(email = nil, from_email = nil)
76
- if email && from_email
75
+ def mail_errors_to(email = nil)
76
+ if email
77
77
  @data[:mail_errors_to] = email
78
- @data[:mail_errors_from] = from_email
79
78
  else
80
79
  @data[:mail_errors_to]
81
80
  end
@@ -122,6 +122,7 @@ module RabbitJobs
122
122
 
123
123
  def startup
124
124
  # prune_dead_workers
125
+ RabbitJobs::Util.check_pidfile(self.pidfile) if self.pidfile
125
126
 
126
127
  Process.daemon(true) if self.background
127
128
 
@@ -0,0 +1,21 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module RabbitJobs::Util
4
+ # clean old worker process
5
+ def self.check_pidfile(pidfile)
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)
12
+
13
+ while Process.kill(0, pid)
14
+ sleep(0.5)
15
+ end
16
+ rescue
17
+ File.delete(pidfile) if File.exists?(pidfile)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module RabbitJobs
2
- VERSION = "0.1.8.2"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -99,6 +99,7 @@ module RabbitJobs
99
99
 
100
100
  def startup
101
101
  # prune_dead_workers
102
+ RabbitJobs::Util.check_pidfile(self.pidfile) if self.pidfile
102
103
 
103
104
  if self.background
104
105
  child_pid = fork
data/lib/rabbit_jobs.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rabbit_jobs/version'
4
4
 
5
+ require 'rabbit_jobs/util'
5
6
  require 'rabbit_jobs/helpers'
6
7
  require 'rabbit_jobs/amqp_helpers'
7
8
  require 'rabbit_jobs/configuration'
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.1.8.2
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-05 00:00:00.000000000 Z
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp
16
- requirement: &70350675513600 !ruby/object:Gem::Requirement
16
+ requirement: &70247572694120 !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: *70350675513600
24
+ version_requirements: *70247572694120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bunny
27
- requirement: &70350675512820 !ruby/object:Gem::Requirement
27
+ requirement: &70247572693100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.7'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70350675512820
35
+ version_requirements: *70247572693100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70350675489860 !ruby/object:Gem::Requirement
38
+ requirement: &70247572691320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70350675489860
46
+ version_requirements: *70247572691320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rufus-scheduler
49
- requirement: &70350675488680 !ruby/object:Gem::Requirement
49
+ requirement: &70247572689800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '2.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70350675488680
57
+ version_requirements: *70247572689800
58
58
  description: Background jobs on RabbitMQ
59
59
  email:
60
60
  - lazureykis@gmail.com
@@ -78,6 +78,7 @@ files:
78
78
  - lib/rabbit_jobs/publisher.rb
79
79
  - lib/rabbit_jobs/scheduler.rb
80
80
  - lib/rabbit_jobs/tasks.rb
81
+ - lib/rabbit_jobs/util.rb
81
82
  - lib/rabbit_jobs/version.rb
82
83
  - lib/rabbit_jobs/worker.rb
83
84
  - lib/tasks/rabbit_jobs.rake
@@ -108,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  segments:
110
111
  - 0
111
- hash: 111001831721435723
112
+ hash: -2922787991343531885
112
113
  required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  none: false
114
115
  requirements:
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  segments:
119
120
  - 0
120
- hash: 111001831721435723
121
+ hash: -2922787991343531885
121
122
  requirements: []
122
123
  rubyforge_project:
123
124
  rubygems_version: 1.8.15