job_boss 0.7.18 → 0.7.19
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/job_boss.gemspec +1 -1
- data/lib/job_boss/boss.rb +0 -2
- data/lib/job_boss/job.rb +24 -23
- metadata +3 -3
data/job_boss.gemspec
CHANGED
data/lib/job_boss/boss.rb
CHANGED
data/lib/job_boss/job.rb
CHANGED
|
@@ -20,30 +20,31 @@ module JobBoss
|
|
|
20
20
|
|
|
21
21
|
# Method used by the boss to dispatch an employee
|
|
22
22
|
def dispatch(boss)
|
|
23
|
-
mark_as_started
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
if mark_as_started
|
|
24
|
+
boss.logger.info "Dispatching Job ##{self.id}: #{self.prototype}"
|
|
25
|
+
|
|
26
|
+
pid = fork do
|
|
27
|
+
ActiveRecord::Base.connection.reconnect!
|
|
28
|
+
$0 = "[job_boss employee] job ##{self.id} #{self.prototype})"
|
|
29
|
+
Process.setpriority(Process::PRIO_PROCESS, 0, 19)
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
mark_employee
|
|
33
|
+
|
|
34
|
+
value = self.class.call_path(self.path, *self.args)
|
|
35
|
+
|
|
36
|
+
self.update_attribute(:result, value)
|
|
37
|
+
rescue Exception => exception
|
|
38
|
+
mark_exception(exception)
|
|
39
|
+
boss.logger.error "Error running job ##{self.id}!"
|
|
40
|
+
ensure
|
|
41
|
+
until mark_as_completed
|
|
42
|
+
sleep(1)
|
|
43
|
+
end
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
mark_exception(exception)
|
|
39
|
-
boss.logger.error "Error running job ##{self.id}!"
|
|
40
|
-
ensure
|
|
41
|
-
until mark_as_completed
|
|
42
|
-
sleep(1)
|
|
45
|
+
boss.logger.info "Job ##{self.id} completed in #{self.time_taken} seconds, exiting..."
|
|
46
|
+
Kernel.exit
|
|
43
47
|
end
|
|
44
|
-
|
|
45
|
-
boss.logger.info "Job ##{self.id} completed in #{self.time_taken} seconds, exiting..."
|
|
46
|
-
Kernel.exit
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
Process.detach(pid)
|
|
@@ -238,7 +239,7 @@ module JobBoss
|
|
|
238
239
|
private
|
|
239
240
|
|
|
240
241
|
def mark_as_started
|
|
241
|
-
|
|
242
|
+
Job.update_all(['started_at = ?', Time.now], ['started_at IS NULL AND id = ?', job]) > 0
|
|
242
243
|
end
|
|
243
244
|
|
|
244
245
|
def mark_as_cancelled
|
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:
|
|
4
|
+
hash: 37
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 7
|
|
9
|
-
-
|
|
10
|
-
version: 0.7.
|
|
9
|
+
- 19
|
|
10
|
+
version: 0.7.19
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Brian Underwood
|