job_boss 0.7.7 → 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/job_boss CHANGED
@@ -24,9 +24,21 @@ Daemons.run_proc('job_boss', daemons_options) do
24
24
 
25
25
  Dir.chdir(JobBoss::Boss.config.application_root)
26
26
 
27
- require 'config/environment' if File.exist?('config/environment.rb')
28
-
29
27
  boss = JobBoss::Boss.new
30
28
 
29
+ if File.exist?('config/environment.rb')
30
+ boss.logger.info "Requiring 'config/environment.rb'"
31
+ require 'config/environment'
32
+ end
33
+
34
+ at_exit do
35
+ puts "Test puts"
36
+ boss.logger.info "Before boss.stop"
37
+ boss.stop
38
+ boss.logger.info "After boss.stop"
39
+ boss = JobBoss::Boss.new
40
+ boss.logger.info "test log!!!!!!!"
41
+ end
42
+
31
43
  boss.start
32
44
  end
data/job_boss.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "job_boss"
7
- s.version = '0.7.7'
7
+ s.version = '0.7.8'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Brian Underwood"]
10
10
  s.email = ["ml+job_boss@semi-sentient.com"]
@@ -37,7 +37,7 @@ module JobBoss
37
37
 
38
38
  # Allow calling of Job class methods from a batch which will be called
39
39
  # on in the scope of the jobs for the batch
40
- # Examples: wait_for_jobs, result_hash, time_taken, completed_percent
40
+ # Examples: wait_for_jobs, result_hash, time_taken, completed_percent, cancelled?
41
41
  def method_missing(sym, *args, &block)
42
42
  jobs.send(sym, *args, &block)
43
43
  end
data/lib/job_boss/boss.rb CHANGED
@@ -75,10 +75,6 @@ module JobBoss
75
75
 
76
76
  require_job_classes
77
77
 
78
- Signal.trap("HUP") do
79
- stop
80
- end
81
-
82
78
  at_exit do
83
79
  stop if Process.pid == BOSS_PID
84
80
  end
data/lib/job_boss/job.rb CHANGED
@@ -173,7 +173,7 @@ module JobBoss
173
173
  # Will cause the process to sleep until all specified jobs have completed
174
174
  # sleep_interval specifies polling period
175
175
  def wait_for_jobs(jobs = nil, sleep_interval = 0.5)
176
- Signal.trap("HUP") do
176
+ at_exit do
177
177
  jobs.each(&:cancel)
178
178
  end
179
179
 
@@ -211,6 +211,14 @@ module JobBoss
211
211
  end
212
212
  end
213
213
 
214
+ def cancelled?(jobs = nil)
215
+ if jobs
216
+ count = Job.where('id in (?)', jobs).where('cancelled_at IS NULL').count
217
+
218
+ !(count > 0)
219
+ end
220
+ end
221
+
214
222
  # Given a time object
215
223
  # Delete all jobs which were completed earlier than that time
216
224
  def delete_jobs_before(time)
@@ -225,7 +233,7 @@ private
225
233
  end
226
234
 
227
235
  def mark_as_cancelled
228
- update_attributes(:cancelled_at => Time.now)
236
+ update_attributes(:cancelled_at => Time.now, :completed_at => Time.now, :status => 'cancelled')
229
237
  end
230
238
 
231
239
  def mark_employee
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_boss
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 7
10
- version: 0.7.7
9
+ - 8
10
+ version: 0.7.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Underwood
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 -05:00
18
+ date: 2011-03-24 00:00:00 -04:00
19
19
  default_executable: job_boss
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency