dronejob 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -13
- data/README.md +4 -0
- data/dronejob.gemspec +1 -1
- data/lib/dronejob/command.rb +13 -27
- data/lib/dronejob/modules/log.rb +5 -3
- data/lib/dronejob/modules/queue.rb +9 -1
- data/lib/dronejob/server.rb +21 -0
- data/lib/dronejob/version.rb +1 -1
- data/lib/dronejob.rb +2 -0
- metadata +14 -14
- data/app.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a310b9d28ba8888a684e9f92c46131ee23085858
|
4
|
+
data.tar.gz: 28b7ffcc75f4011b8355cd44c0a9672420f5e8d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d3b332ca2191fbdec6fc587461aa156ad57ac01bee4bde8281e225aa03715e7a4a968fd78381b612f25b7a8bfcef92114a92c205704bbd9f0359a766f371541
|
7
|
+
data.tar.gz: f9b6f3f71e441f7d29f8ac3d8277be31f0d1e36661dcafafbdb930b18f6c3226137fe12035c8b966456b76ebcca4dfe469f52502f34352497f5c5312356aebfb
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dronejob (
|
4
|
+
dronejob (2.0.0)
|
5
5
|
actionpack (>= 4.0.2)
|
6
6
|
activejob (>= 4.0.2)
|
7
|
+
activejob-google_cloud_pubsub (>= 0.7)
|
7
8
|
bundler (>= 1.12.0, < 3.0.0)
|
8
9
|
git (>= 1.3)
|
9
10
|
google-cloud-logging (>= 1.2)
|
10
11
|
pusher (>= 1.3)
|
11
|
-
sidekiq (>= 5.0)
|
12
12
|
thor (>= 0.19)
|
13
13
|
workspace (>= 1.0)
|
14
14
|
workspace-archive (>= 1.0)
|
@@ -35,6 +35,11 @@ GEM
|
|
35
35
|
activejob (5.2.3)
|
36
36
|
activesupport (= 5.2.3)
|
37
37
|
globalid (>= 0.3.6)
|
38
|
+
activejob-google_cloud_pubsub (0.7.1)
|
39
|
+
activejob
|
40
|
+
activesupport
|
41
|
+
concurrent-ruby
|
42
|
+
google-cloud-pubsub (>= 0.27.0)
|
38
43
|
activesupport (5.2.3)
|
39
44
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
40
45
|
i18n (>= 0.7, < 2)
|
@@ -46,7 +51,6 @@ GEM
|
|
46
51
|
builder (3.2.3)
|
47
52
|
coderay (1.1.2)
|
48
53
|
concurrent-ruby (1.1.5)
|
49
|
-
connection_pool (2.2.2)
|
50
54
|
crass (1.0.4)
|
51
55
|
diff-lcs (1.3)
|
52
56
|
erubi (1.8.0)
|
@@ -68,13 +72,18 @@ GEM
|
|
68
72
|
google-gax (~> 1.3)
|
69
73
|
googleapis-common-protos-types (>= 1.0.2)
|
70
74
|
stackdriver-core (~> 1.3)
|
75
|
+
google-cloud-pubsub (0.30.2)
|
76
|
+
concurrent-ruby (~> 1.0)
|
77
|
+
google-cloud-core (~> 1.2)
|
78
|
+
google-gax (~> 1.0)
|
79
|
+
grpc-google-iam-v1 (~> 0.6.9)
|
71
80
|
google-gax (1.5.0)
|
72
81
|
google-protobuf (~> 3.2)
|
73
82
|
googleapis-common-protos (>= 1.3.5, < 2.0)
|
74
83
|
googleauth (>= 0.6.2, < 0.10.0)
|
75
84
|
grpc (>= 1.7.2, < 2.0)
|
76
85
|
rly (~> 0.2.3)
|
77
|
-
google-protobuf (3.7.1)
|
86
|
+
google-protobuf (3.7.1-universal-darwin)
|
78
87
|
googleapis-common-protos (1.3.9)
|
79
88
|
google-protobuf (~> 3.0)
|
80
89
|
googleapis-common-protos-types (~> 1.0)
|
@@ -88,9 +97,12 @@ GEM
|
|
88
97
|
multi_json (~> 1.11)
|
89
98
|
os (>= 0.9, < 2.0)
|
90
99
|
signet (~> 0.7)
|
91
|
-
grpc (1.20.0)
|
100
|
+
grpc (1.20.0-universal-darwin)
|
92
101
|
google-protobuf (~> 3.7)
|
93
102
|
googleapis-common-protos-types (~> 1.0.0)
|
103
|
+
grpc-google-iam-v1 (0.6.9)
|
104
|
+
googleapis-common-protos (>= 1.3.1, < 2.0)
|
105
|
+
grpc (~> 1.0)
|
94
106
|
haml (5.1.0)
|
95
107
|
temple (>= 0.8.0)
|
96
108
|
tilt
|
@@ -130,8 +142,6 @@ GEM
|
|
130
142
|
pusher-signature (~> 0.1.8)
|
131
143
|
pusher-signature (0.1.8)
|
132
144
|
rack (2.0.7)
|
133
|
-
rack-protection (2.0.5)
|
134
|
-
rack
|
135
145
|
rack-test (1.1.0)
|
136
146
|
rack (>= 1.0, < 3)
|
137
147
|
rails-dom-testing (2.0.3)
|
@@ -140,7 +150,6 @@ GEM
|
|
140
150
|
rails-html-sanitizer (1.0.4)
|
141
151
|
loofah (~> 2.2, >= 2.2.2)
|
142
152
|
rainbow (3.0.0)
|
143
|
-
redis (4.1.1)
|
144
153
|
rly (0.2.3)
|
145
154
|
rmagick (2.16.0)
|
146
155
|
rspec (3.8.0)
|
@@ -165,11 +174,6 @@ GEM
|
|
165
174
|
unicode-display_width (>= 1.4.0, < 1.7)
|
166
175
|
ruby-progressbar (1.10.0)
|
167
176
|
rubyzip (1.2.2)
|
168
|
-
sidekiq (5.2.7)
|
169
|
-
connection_pool (~> 2.2, >= 2.2.2)
|
170
|
-
rack (>= 1.5.0)
|
171
|
-
rack-protection (>= 1.5.0)
|
172
|
-
redis (>= 3.3.5, < 5)
|
173
177
|
signet (0.11.0)
|
174
178
|
addressable (~> 2.3)
|
175
179
|
faraday (~> 0.9)
|
data/README.md
CHANGED
data/dronejob.gemspec
CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency "bundler", "< 3.0.0", ">= 1.12.0"
|
18
18
|
s.add_runtime_dependency "actionpack", ">= 4.0.2"
|
19
19
|
s.add_runtime_dependency "activejob", ">= 4.0.2"
|
20
|
+
s.add_runtime_dependency "activejob-google_cloud_pubsub", ">= 0.7"
|
20
21
|
s.add_runtime_dependency "git", ">= 1.3"
|
21
22
|
s.add_runtime_dependency "google-cloud-logging", ">= 1.2"
|
22
23
|
s.add_runtime_dependency "pusher", ">= 1.3"
|
23
|
-
s.add_runtime_dependency "sidekiq", ">= 5.0"
|
24
24
|
s.add_runtime_dependency "thor", ">= 0.19"
|
25
25
|
s.add_runtime_dependency "workspace", ">= 1.0"
|
26
26
|
s.add_runtime_dependency "workspace-archive", ">= 1.0"
|
data/lib/dronejob/command.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
require "dronejob"
|
2
2
|
require "active_job"
|
3
|
+
|
3
4
|
module Dronejob
|
4
5
|
class Command < Thor
|
5
6
|
Dronejob::Loader.workers(:base).each do |identifier, worker|
|
6
7
|
desc identifier, "Queue #{identifier} worker"
|
7
8
|
|
8
|
-
# Pub/Sub options
|
9
|
-
method_option(:queue_adapter, type: :string, default: "sidekiq")
|
10
|
-
|
11
9
|
# Worker options
|
12
10
|
method_option(:run, aliases: "-r", type: :boolean, default: false)
|
13
11
|
method_option(:break, aliases: "-b", type: :boolean, default: false)
|
14
12
|
method_option(:skip, aliases: "-s", type: :array, default: [])
|
15
13
|
method_option(:from, aliases: "-f", type: :string)
|
16
|
-
method_option(:listen, aliases: "-l", type: :boolean, default: false)
|
17
14
|
method_option(:notify, aliases: "-n", type: :boolean, default: true)
|
18
15
|
method_option(:jobs_path, type: :string)
|
19
16
|
method_option(:output_path, type: :string)
|
@@ -24,7 +21,6 @@ module Dronejob
|
|
24
21
|
end
|
25
22
|
|
26
23
|
define_method(identifier) do
|
27
|
-
Dronejob::Base.queue_adapter = options.queue_adapter
|
28
24
|
Dronejob::Base.jobs_path = options.jobs_path if options.jobs_path
|
29
25
|
Dronejob::Base.output_path = options.output_path if options.output_path
|
30
26
|
|
@@ -32,28 +28,8 @@ module Dronejob
|
|
32
28
|
if options.run
|
33
29
|
worker.perform_now(options)
|
34
30
|
else
|
35
|
-
Sidekiq.configure_client do |config|
|
36
|
-
config.redis = { url: Dronejob::Base.options.redis_url }
|
37
|
-
end
|
38
31
|
job = worker.perform_later(options.to_hash)
|
39
|
-
|
40
|
-
# Listen for notifications
|
41
|
-
if options.listen
|
42
|
-
if options.run or !options.notify
|
43
|
-
Dronejob::Base.log("error", "Unable to listen to a jobs that '--run' instantly, or with '--no-notify' set")
|
44
|
-
else
|
45
|
-
Dronejob::Base.subscribe(Dronejob::Base.status_topic, true) do |data|
|
46
|
-
if data["job_id"] == job.job_id
|
47
|
-
Dronejob::Base.log("info", "status: #{data['detail'].to_json}")
|
48
|
-
if data["detail"]["phase"] == "complete"
|
49
|
-
Dronejob::Base.log("info", "job completed")
|
50
|
-
Kernel.exit
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
32
|
+
Dronejob::Base.log("info", "Enqueued job #{job.job_id}")
|
57
33
|
end
|
58
34
|
end
|
59
35
|
end
|
@@ -109,8 +85,18 @@ module Dronejob
|
|
109
85
|
job_identifier = dronejob_config[:job_identifier]
|
110
86
|
worker = Dronejob::Loader.workers[job_identifier]
|
111
87
|
job_params["from"] = options.from
|
112
|
-
Dronejob::Base.queue_adapter = job_params["queue_adapter"]
|
113
88
|
worker.perform_now(job_params)
|
114
89
|
end
|
90
|
+
|
91
|
+
desc :server, "Start Dronejob Server"
|
92
|
+
def server
|
93
|
+
server = Server.new(Dronejob::Base.options)
|
94
|
+
begin
|
95
|
+
server.start
|
96
|
+
rescue Interrupt
|
97
|
+
server.stop
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
end
|
115
101
|
end
|
116
102
|
end
|
data/lib/dronejob/modules/log.rb
CHANGED
@@ -30,7 +30,7 @@ module Dronejob
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class_methods do
|
33
|
-
def log(level, message, job)
|
33
|
+
def log(level, message, job = nil)
|
34
34
|
if !logger.nil?
|
35
35
|
if option(:dronejob_log) == "google"
|
36
36
|
message = "[#{job.job_id}] #{message}" if level != :error
|
@@ -38,15 +38,17 @@ module Dronejob
|
|
38
38
|
# data[:phase] = job.phase.to_s if job.phase
|
39
39
|
# data[:user_id] = job.param(:user_id) if job.param(:user_id)
|
40
40
|
data[:phase_title] = job.phase_config[:title].to_s if job.phase_config&.key?(:title)
|
41
|
-
if job
|
41
|
+
if job&.phase_config&.key?(:progress)
|
42
42
|
data[:phase_progress] = job.phase_config[:progress]
|
43
43
|
end
|
44
44
|
logger.send(level, data.compact)
|
45
45
|
else
|
46
46
|
logger.send(level, message)
|
47
47
|
end
|
48
|
-
|
48
|
+
elsif job
|
49
49
|
puts "#{level}: [#{job.phase}] #{message}"
|
50
|
+
else
|
51
|
+
puts "#{level}: #{message}"
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -1,17 +1,25 @@
|
|
1
1
|
require "pusher"
|
2
|
+
|
2
3
|
module Dronejob
|
3
4
|
module Modules
|
4
5
|
module Queue
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
8
|
included do
|
8
|
-
attr_accessor :queue_adapter
|
9
9
|
queue_as option(:dronejob_queue) || :dronejob
|
10
10
|
set_callback :phase, :before, :notify_before_phase
|
11
11
|
set_callback :job, :after, :notify_after_job
|
12
12
|
end
|
13
13
|
|
14
14
|
class_methods do
|
15
|
+
def pubsub
|
16
|
+
@pubsub ||= Google::Cloud::Pubsub.new(project_id: option(:google_cloud_project_id), credentials: option(:google_cloud_service_account))
|
17
|
+
end
|
18
|
+
|
19
|
+
def queue_adapter
|
20
|
+
@queue_adapter ||= ActiveJob::GoogleCloudPubsub::Adapter.new(async: false, logger: logger, pubsub: pubsub)
|
21
|
+
end
|
22
|
+
|
15
23
|
def notify(value = true)
|
16
24
|
@notify = value
|
17
25
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Dronejob
|
2
|
+
class Dronejob::Server
|
3
|
+
attr_reader :worker, :queue, :min_threads, :max_threads
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@queue = options.dronejob_queue || "drone"
|
7
|
+
@min_threads = options.min_threads || 1
|
8
|
+
@max_threads = options.max_threads || 1
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
@worker = ActiveJob::GoogleCloudPubsub::Worker.new(queue: @queue, pubsub: Dronejob::Base.pubsub, min_threads: self.min_threads, max_threads: self.max_threads)
|
13
|
+
Dronejob::Base.log("info", "Starting server for queue #{@queue} ...", nil)
|
14
|
+
@worker.run
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop
|
18
|
+
Dronejob::Base.log("info", "Stopping server ...", nil)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/dronejob/version.rb
CHANGED
data/lib/dronejob.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dronejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
@@ -59,61 +59,61 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 4.0.2
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: activejob-google_cloud_pubsub
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '0.7'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '0.7'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: git
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '1.
|
81
|
+
version: '1.3'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '1.
|
88
|
+
version: '1.3'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: google-cloud-logging
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '1.
|
95
|
+
version: '1.2'
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '1.
|
102
|
+
version: '1.2'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
104
|
+
name: pusher
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '1.3'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
116
|
+
version: '1.3'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: thor
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,7 +253,6 @@ files:
|
|
253
253
|
- Gemfile
|
254
254
|
- Gemfile.lock
|
255
255
|
- README.md
|
256
|
-
- app.rb
|
257
256
|
- bin/dronejob
|
258
257
|
- dronejob.gemspec
|
259
258
|
- lib/dronejob.rb
|
@@ -272,6 +271,7 @@ files:
|
|
272
271
|
- lib/dronejob/modules/workspace.rb
|
273
272
|
- lib/dronejob/railtie.rb
|
274
273
|
- lib/dronejob/railties/dronejob.rake
|
274
|
+
- lib/dronejob/server.rb
|
275
275
|
- lib/dronejob/version.rb
|
276
276
|
homepage: https://github.com/MagLoft/dronejob
|
277
277
|
licenses:
|