steve 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/active_job/queue_adapters/steve_adapter.rb +23 -0
- data/lib/steve.rb +0 -1
- data/lib/steve/queued_job.rb +4 -9
- metadata +12 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 39ac8bc8cd9c5647e61a09673bcc96fed956fb57
|
4
|
+
data.tar.gz: 552ae88ed5ed4968234701ddc338f4d08bdc9be2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e7f58a6af65971bd4d64a061617d32925931cf8db09d3ee432ce77711d6cecc17f01dbc8a8061b08ff2ca43b87af31d4e3150629a11772cc4079294777d6c7c
|
7
|
+
data.tar.gz: 2725c97343de78b411c98b4703c1aad5d64dcece8da36c74543e74722b20e70390c19a89e32fcdcc6842157519fba354947c62ec20283838a13e7bab4a300a6f
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveJob
|
2
|
+
module QueueAdapters
|
3
|
+
class SteveAdapter
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def enqueue(job)
|
7
|
+
JobWrapper.queue(job.serialize)
|
8
|
+
end
|
9
|
+
|
10
|
+
def enqueue_at(job, timestamp)
|
11
|
+
raise NotImplementedError
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class JobWrapper < Steve::Job
|
16
|
+
def perform
|
17
|
+
Base.execute(params)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/steve.rb
CHANGED
data/lib/steve/queued_job.rb
CHANGED
@@ -44,28 +44,23 @@ module Steve
|
|
44
44
|
## Execute a new job from the queue. Returns true if a job was executed, or false if a
|
45
45
|
## job was not found or we couldn't obtain locks for them.
|
46
46
|
def self.execute_jobs(queue = '*', limit = 5)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
jobs.all
|
51
|
-
end
|
47
|
+
jobs = self.where(:status => ['pending', 'delayed'], :worker => nil).where(["run_at <= ?", Time.now.utc]).order("priority asc").limit(5)
|
48
|
+
jobs = jobs.where(:queue => queue) unless queue.nil? or queue == '*'
|
49
|
+
pending_jobs = jobs.all
|
52
50
|
|
53
51
|
jobs_executed = Array.new
|
54
52
|
for job in pending_jobs.sort_by { rand() }
|
55
53
|
Steve.log "[#{job.id}] Attempt to aquire lock"
|
56
54
|
if job.lock
|
57
55
|
Steve.log "[#{job.id}] Lock acquired"
|
58
|
-
ActiveRecord::Base.remove_connection
|
59
56
|
if @child = fork
|
60
57
|
rand
|
61
58
|
Steve.log "[#{job.id}] Forked to #{@child}"
|
62
59
|
$0 = "sj: forked to #{@child} at #{Time.now.utc.to_s(:db)}" unless Steve.keep_parent_process_name
|
63
|
-
ActiveRecord::Base.establish_connection
|
64
60
|
Process.wait
|
65
61
|
else
|
66
62
|
Steve.log "[#{job.id}] Executing"
|
67
63
|
$0 = "sj: executing job ##{job.id} since #{Time.now.utc.to_s(:db)}"
|
68
|
-
ActiveRecord::Base.establish_connection
|
69
64
|
Steve.after_job_fork.call if Steve.after_job_fork.is_a?(Proc)
|
70
65
|
job.execute
|
71
66
|
exit
|
@@ -141,7 +136,7 @@ module Steve
|
|
141
136
|
## Get a lock on this job. Returns true if the lock was successful
|
142
137
|
## otherwise it returns false.
|
143
138
|
def lock
|
144
|
-
rows = self.class.
|
139
|
+
rows = self.class.where(:id => self.id, :worker => nil).update_all(:worker => Steve.worker_name)
|
145
140
|
if rows == 1
|
146
141
|
self.worker = Steve.worker_name
|
147
142
|
return true
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- aTech Media
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: will_paginate
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
description:
|
@@ -33,40 +30,40 @@ executables: []
|
|
33
30
|
extensions: []
|
34
31
|
extra_rdoc_files: []
|
35
32
|
files:
|
33
|
+
- lib/active_job/queue_adapters/steve_adapter.rb
|
34
|
+
- lib/steve.rb
|
36
35
|
- lib/steve/archived_job.rb
|
36
|
+
- lib/steve/interface.rb
|
37
37
|
- lib/steve/interface/public/style.css
|
38
38
|
- lib/steve/interface/views/completed.haml
|
39
39
|
- lib/steve/interface/views/failed.haml
|
40
40
|
- lib/steve/interface/views/index.haml
|
41
41
|
- lib/steve/interface/views/object.haml
|
42
42
|
- lib/steve/interface/views/view.haml
|
43
|
-
- lib/steve/interface.rb
|
44
43
|
- lib/steve/job.rb
|
45
44
|
- lib/steve/queued_job.rb
|
46
45
|
- lib/steve/worker.rb
|
47
|
-
- lib/steve.rb
|
48
46
|
homepage: http://atechmedia.com
|
49
47
|
licenses: []
|
48
|
+
metadata: {}
|
50
49
|
post_install_message:
|
51
50
|
rdoc_options: []
|
52
51
|
require_paths:
|
53
52
|
- lib
|
54
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
54
|
requirements:
|
57
|
-
- -
|
55
|
+
- - ">="
|
58
56
|
- !ruby/object:Gem::Version
|
59
57
|
version: '0'
|
60
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
59
|
requirements:
|
63
|
-
- -
|
60
|
+
- - ">="
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: '0'
|
66
63
|
requirements: []
|
67
64
|
rubyforge_project:
|
68
|
-
rubygems_version:
|
65
|
+
rubygems_version: 2.2.2
|
69
66
|
signing_key:
|
70
|
-
specification_version:
|
67
|
+
specification_version: 4
|
71
68
|
summary: Steve Jobs background job runner
|
72
69
|
test_files: []
|