rabbit_jobs 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ module RabbitJobs
83
83
 
84
84
  # Subscribes to channel and working on jobs
85
85
  def work(time = 0)
86
- startup
86
+ return false unless startup
87
87
 
88
88
  $0 = self.process_name || "rj_scheduler"
89
89
 
@@ -113,6 +113,8 @@ module RabbitJobs
113
113
  check_shutdown.call
114
114
  end
115
115
  end
116
+
117
+ true
116
118
  end
117
119
 
118
120
  def shutdown
@@ -125,13 +127,12 @@ module RabbitJobs
125
127
  RabbitJobs::Util.check_pidfile(self.pidfile) if self.pidfile
126
128
 
127
129
  if self.background
128
- Process.daemon(true)
129
-
130
- if defined?(ActiveRecord::Base)
131
- ActiveRecord::Base.establish_connection
132
- end
133
- if defined?(MongoMapper)
134
- MongoMapper.database.connection.connect_to_master
130
+ child_pid = fork
131
+ if child_pid
132
+ return false
133
+ else
134
+ # daemonize child process
135
+ Process.daemon(true)
135
136
  end
136
137
  end
137
138
 
@@ -147,6 +148,8 @@ module RabbitJobs
147
148
 
148
149
  Signal.trap('TERM') { shutdown }
149
150
  Signal.trap('INT') { shutdown! }
151
+
152
+ true
150
153
  end
151
154
 
152
155
  def shutdown!
@@ -1,3 +1,3 @@
1
1
  module RabbitJobs
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
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.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  segments:
131
131
  - 0
132
- hash: -4338471545654317005
132
+ hash: 2915034037780262995
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  none: false
135
135
  requirements:
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: -4338471545654317005
141
+ hash: 2915034037780262995
142
142
  requirements: []
143
143
  rubyforge_project:
144
144
  rubygems_version: 1.8.24