dronejob 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app.rb +2 -0
- data/lib/dronejob.rb +14 -0
- data/lib/dronejob/banner.rb +12 -0
- data/lib/dronejob/base.rb +2 -3
- data/lib/dronejob/command.rb +0 -13
- data/lib/dronejob/modules/log.rb +34 -7
- data/lib/dronejob/modules/queue.rb +1 -11
- data/lib/dronejob/version.rb +1 -1
- data/lib/dronejob/workspace_file/parse.rb +0 -1
- metadata +3 -2
- data/lib/dronejob/server/sidekiq.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d289e8680b74218314d2494741bcea27c1433408
|
4
|
+
data.tar.gz: 9d709407b987a68b9575e9417f7b3cc876c6b626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3651cd2b5f05d27d785382ce476385dca08199b7fc0cc1bae9de5cd9a291ec31402a88d00a981f52c3617a3850f90f084a32b9a99cc498f221dc3b4ef643c497
|
7
|
+
data.tar.gz: 255e1b4a054280eb2621663835467fa60cde4f420da2b56c546458120f643ef2509eda9e20be4fcf330dbb53efc355da9caceb7681a44b4a2210244cc4ca5360
|
data/Gemfile.lock
CHANGED
data/app.rb
ADDED
data/lib/dronejob.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "active_support"
|
2
2
|
require 'active_support/rails'
|
3
3
|
require "dronejob/version"
|
4
|
+
require "psych"
|
4
5
|
|
5
6
|
require 'dronejob/railtie' if defined?(Rails)
|
6
7
|
|
@@ -8,4 +9,17 @@ module Dronejob
|
|
8
9
|
extend ActiveSupport::Autoload
|
9
10
|
autoload :Base
|
10
11
|
autoload :Loader
|
12
|
+
|
13
|
+
def self.start
|
14
|
+
require "dronejob/banner"
|
15
|
+
require "sidekiq-status"
|
16
|
+
Loader.load
|
17
|
+
Dronejob::Base.queue_adapter = "sidekiq"
|
18
|
+
Sidekiq.configure_server do |config|
|
19
|
+
config.redis = { url: Dronejob::Base.options.redis_url }
|
20
|
+
config.server_middleware do |chain|
|
21
|
+
chain.add Sidekiq::Status::ServerMiddleware
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
11
25
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
class CLI
|
3
|
+
def self.banner
|
4
|
+
' ___ _ _ ' + "\n" +
|
5
|
+
' | \ _ _ ___ _ _ ___ _ | | ___ | |__ ' + "\n" +
|
6
|
+
' | |) | | `_| / _ \ | ` \ / -_) | || | / _ \ | `_ \ ' + "\n" +
|
7
|
+
' |___/ _|_|_ \___/ |_||_| \___| _\__/ \___/ |_.__/ ' + "\n" +
|
8
|
+
' _|=====|_|=====|_|=====|_|=====|_|=====|_|=====|_|=====|_|=====| ' + "\n" +
|
9
|
+
' =`-0-0-`=`-0-0-`=`-0-0-`=`-0-0-`=`-0-0-`=`-0-0-`=`-0-0-`=`-0-0-` '
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/dronejob/base.rb
CHANGED
@@ -13,17 +13,16 @@ require 'dronejob/modules/workspace'
|
|
13
13
|
module Dronejob
|
14
14
|
class Base < ActiveJob::Base
|
15
15
|
DRONEJOB_TYPE = "base"
|
16
|
-
queue_as :dronejob
|
17
16
|
include Modules::AttrStore
|
18
17
|
include Modules::Callbacks
|
19
18
|
include Modules::Core
|
20
19
|
include Modules::Git
|
21
|
-
include Modules::Log
|
22
|
-
include Modules::Queue
|
23
20
|
include Modules::Options
|
21
|
+
include Modules::Queue
|
24
22
|
include Modules::Params
|
25
23
|
include Modules::Phases
|
26
24
|
include Modules::Workspace
|
25
|
+
include Modules::Log
|
27
26
|
|
28
27
|
def uuid
|
29
28
|
@uuid ||= "#{self.class.name.split('::').last.underscore}_#{SecureRandom.uuid}"
|
data/lib/dronejob/command.rb
CHANGED
@@ -59,19 +59,6 @@ module Dronejob
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
desc :server, "Start Dronejob Server"
|
63
|
-
method_option(:queue_adapter, type: :string, default: "sidekiq", enum: ["sidekiq"])
|
64
|
-
method_option(:jobs_path, type: :string)
|
65
|
-
method_option(:output_path, type: :string)
|
66
|
-
def server
|
67
|
-
Dronejob::Base.queue_adapter = options.queue_adapter if options.queue_adapter
|
68
|
-
Dronejob::Base.jobs_path = options.jobs_path if options.jobs_path
|
69
|
-
Dronejob::Base.output_path = options.output_path if options.output_path
|
70
|
-
|
71
|
-
# Run worker
|
72
|
-
Dronejob::Base.run_worker!
|
73
|
-
end
|
74
|
-
|
75
62
|
desc :archive, "Archive Completed Jobs"
|
76
63
|
method_option(:force, aliases: "-f", type: :boolean, default: false)
|
77
64
|
def archive
|
data/lib/dronejob/modules/log.rb
CHANGED
@@ -4,9 +4,24 @@ module Dronejob
|
|
4
4
|
module Modules
|
5
5
|
module Log
|
6
6
|
extend ActiveSupport::Concern
|
7
|
+
COLOR_BOLD = "\e[1m"
|
8
|
+
COLOR_RED = "\e[31m"
|
9
|
+
COLOR_RED_BG = "\e[41m"
|
10
|
+
COLOR_WHITE = "\e[38;5;15m"
|
11
|
+
COLOR_GREY = "\e[38;5;245m"
|
12
|
+
COLOR_GREY_BG = "\e[48;5;255m"
|
13
|
+
COLOR_END = "\e[0m"
|
7
14
|
|
8
15
|
included do
|
9
|
-
cattr_accessor(:logger)
|
16
|
+
cattr_accessor(:logger) do
|
17
|
+
dronejob_log = option(:dronejob_log) || "STDOUT"
|
18
|
+
if dronejob_log == "STDOUT"
|
19
|
+
custom_logger = ActiveSupport::Logger.new(STDOUT)
|
20
|
+
else
|
21
|
+
custom_logger = ActiveSupport::Logger.new(dronejob_log)
|
22
|
+
end
|
23
|
+
ActiveSupport::TaggedLogging.new(custom_logger)
|
24
|
+
end
|
10
25
|
end
|
11
26
|
|
12
27
|
class_methods do
|
@@ -41,9 +56,11 @@ module Dronejob
|
|
41
56
|
|
42
57
|
def error(message)
|
43
58
|
if Exception === message
|
44
|
-
|
45
|
-
|
46
|
-
|
59
|
+
if log_stdout?
|
60
|
+
log(:error, "#{COLOR_RED_BG}#{COLOR_BOLD}#{COLOR_WHITE} ERROR #{COLOR_END} #{COLOR_BOLD}#{message.class}: #{COLOR_RED}#{message.message}#{COLOR_END}")
|
61
|
+
else
|
62
|
+
log(:error, "[ERROR] #{message.class}: #{message.message}")
|
63
|
+
end
|
47
64
|
backtrace(message.backtrace)
|
48
65
|
else
|
49
66
|
log(:error, message)
|
@@ -55,9 +72,11 @@ module Dronejob
|
|
55
72
|
line.gsub!("#{Dir.pwd}/", '')
|
56
73
|
(file, lineno, info) = line.split(":")
|
57
74
|
if /ruby\/?gems/.match(line).nil?
|
58
|
-
|
59
|
-
|
60
|
-
|
75
|
+
if log_stdout?
|
76
|
+
log(:error, "#{COLOR_GREY_BG}#{COLOR_GREY} #{lineno.rjust(5, ' ')} #{COLOR_END} #{COLOR_RED}#{file}#{COLOR_END} #{COLOR_GREY}#{info}#{COLOR_END}")
|
77
|
+
else
|
78
|
+
log(:error, " - #{file}:#{lineno} #{info}")
|
79
|
+
end
|
61
80
|
end
|
62
81
|
end
|
63
82
|
end
|
@@ -77,6 +96,14 @@ module Dronejob
|
|
77
96
|
def emergency(message)
|
78
97
|
log(:emergency, message)
|
79
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def log_stdout?
|
103
|
+
logdev = logger.instance_variable_get("@logdev")
|
104
|
+
logger_source = logdev.dev if logdev.respond_to?(:dev)
|
105
|
+
STDOUT === logger_source
|
106
|
+
end
|
80
107
|
end
|
81
108
|
end
|
82
109
|
end
|
@@ -5,21 +5,11 @@ module Dronejob
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
attr_accessor :queue_adapter
|
8
|
+
queue_as option(:dronejob_queue) || :dronejob
|
8
9
|
set_callback :phase, :before, :notify_before_phase
|
9
10
|
set_callback :job, :after, :notify_after_job
|
10
11
|
end
|
11
12
|
|
12
|
-
class_methods do
|
13
|
-
def run_worker!
|
14
|
-
ActiveJob::Base.queue_adapter = self.queue_adapter
|
15
|
-
require 'sidekiq/cli'
|
16
|
-
$:.push("./")
|
17
|
-
cli = Sidekiq::CLI.instance
|
18
|
-
cli.parse(["-q#{option(:dronejob_queue) || "dronejob"}", "-rlib/dronejob/server/sidekiq.rb"])
|
19
|
-
cli.run
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
13
|
def publish_status(data={}, status="working", backend=false)
|
24
14
|
data[:action] = "update_process"
|
25
15
|
data[:user_id] = param(:user_id)
|
data/lib/dronejob/version.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: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
@@ -196,9 +196,11 @@ files:
|
|
196
196
|
- Gemfile
|
197
197
|
- Gemfile.lock
|
198
198
|
- README.md
|
199
|
+
- app.rb
|
199
200
|
- bin/dronejob
|
200
201
|
- dronejob.gemspec
|
201
202
|
- lib/dronejob.rb
|
203
|
+
- lib/dronejob/banner.rb
|
202
204
|
- lib/dronejob/base.rb
|
203
205
|
- lib/dronejob/command.rb
|
204
206
|
- lib/dronejob/loader.rb
|
@@ -214,7 +216,6 @@ files:
|
|
214
216
|
- lib/dronejob/modules/workspace.rb
|
215
217
|
- lib/dronejob/railtie.rb
|
216
218
|
- lib/dronejob/railties/dronejob.rake
|
217
|
-
- lib/dronejob/server/sidekiq.rb
|
218
219
|
- lib/dronejob/version.rb
|
219
220
|
- lib/dronejob/workspace_dir.rb
|
220
221
|
- lib/dronejob/workspace_dir/archive.rb
|