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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4945a0a8896b7c9bf4ce1f0672c086e0a9dfe956
4
- data.tar.gz: 1b41875621ed5d31aad837edd0354c089743b9db
3
+ metadata.gz: d289e8680b74218314d2494741bcea27c1433408
4
+ data.tar.gz: 9d709407b987a68b9575e9417f7b3cc876c6b626
5
5
  SHA512:
6
- metadata.gz: 69466465ebaf6db5b03d0b77c461e4421385bb0abde2c90f2addb337017b6deb69850ca0a69ca6b56a01d38812fa918cc3f9f88b5d890d6073eb9671bc068fb5
7
- data.tar.gz: 41c3a2ab4bb915018763550db1652621b0c2100f2b492c0cd93fb8bd1dbd435cb22ed21c8db59834c562d5ca8d71d409cc59a6b71322d11ccffce58dbba18d2b
6
+ metadata.gz: 3651cd2b5f05d27d785382ce476385dca08199b7fc0cc1bae9de5cd9a291ec31402a88d00a981f52c3617a3850f90f084a32b9a99cc498f221dc3b4ef643c497
7
+ data.tar.gz: 255e1b4a054280eb2621663835467fa60cde4f420da2b56c546458120f643ef2509eda9e20be4fcf330dbb53efc355da9caceb7681a44b4a2210244cc4ca5360
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dronejob (1.1.1)
4
+ dronejob (1.1.2)
5
5
  activejob (~> 4.2)
6
6
  bundler (>= 1.3.0, < 2.0)
7
7
  git (~> 1.2)
data/app.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "dronejob"
2
+ Dronejob.start
@@ -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
@@ -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}"
@@ -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
@@ -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) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
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
- say(" ERROR ", ["\e[38;5;15m", Thor::Shell::Color::BOLD, Thor::Shell::Color::ON_RED], false)
45
- say(" #{message.class}: ", [Thor::Shell::Color::BOLD], false)
46
- say("#{message.message}", [Thor::Shell::Color::BOLD, Thor::Shell::Color::RED])
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
- say(" #{lineno.rjust(5, ' ')} ", ["\e[48;5;255m", "\e[38;5;245m"], false)
59
- say(" #{file} ", [Thor::Shell::Color::RED], false)
60
- say(info, ["\e[38;5;245m"], true)
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)
@@ -1,3 +1,3 @@
1
1
  module Dronejob
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -23,7 +23,6 @@ module Dronejob
23
23
  end
24
24
 
25
25
  def read_yaml
26
- require "psych"
27
26
  Psych.load_file(to_s)
28
27
  end
29
28
 
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.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
@@ -1,7 +0,0 @@
1
- require "sidekiq-status"
2
- Sidekiq.configure_server do |config|
3
- config.redis = { url: Dronejob::Base.options.redis_url }
4
- config.server_middleware do |chain|
5
- chain.add Sidekiq::Status::ServerMiddleware
6
- end
7
- end