rocketjob 3.4.0 → 3.4.1

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: faa325cab5ef48e8da02dc8310ab2a2098670b7b
4
- data.tar.gz: 273ee417e36f6e69123c345d967d92e1efd77c1c
3
+ metadata.gz: abb40a0f5b7abce954efc71891845f43088af58b
4
+ data.tar.gz: 554a9d1df074fff449db727ce2bba2dcae8867b0
5
5
  SHA512:
6
- metadata.gz: c833153f3eb38d8e7c5bcdb1c691dc5edc51fbde013e07a0f7a5c488cee848c77b573218c4cb1f04da2b06a6feadb8e30bd435dcbc3516e0291330eff459cd2a
7
- data.tar.gz: 70cfc47e8b4383d2d61fc6ed99d4672784a4128ebb03f270a7ef667a1f6217a754d2a6a937e92caf909e9850ca78c85f4bb688aa89e970b3b32369abcfc68863
6
+ metadata.gz: 0ef4cff6fac8bb64b10b8b4be0a2c4b2e009510f964619423c8604ed78710a0712fe2a2cdf3e5a88450d233eaba74d999d6094f344f6ae53841abd223f1c622b
7
+ data.tar.gz: 7fcb27f62e344fe38ca20fae4178e021baafa955644abf9420d8970a250d7c59a24c41e488201bc47b140d03aad03a8772618ae68df0cc22e8c8757be3ee4afb
@@ -2,6 +2,7 @@ require 'optparse'
2
2
  require 'semantic_logger'
3
3
  require 'mongoid'
4
4
  require 'rocketjob'
5
+ require 'rocket_job/extensions/mongoid/factory'
5
6
  module RocketJob
6
7
  # Command Line Interface parser for RocketJob
7
8
  class CLI
@@ -35,7 +36,7 @@ module RocketJob
35
36
  write_pidfile
36
37
 
37
38
  # In case Rails did not load the Mongoid Config
38
- RocketJob::Config.load!(environment, mongo_config, symmetric_encryption_config) if Mongoid::Config.clients.empty?
39
+ RocketJob::Config.load!(environment, mongo_config, symmetric_encryption_config) if ::Mongoid::Config.clients.empty?
39
40
 
40
41
  opts = {}
41
42
  opts[:name] = name if name
@@ -132,8 +133,8 @@ module RocketJob
132
133
  # Enable SemanticLogger signal handling for this process
133
134
  SemanticLogger.add_signal_handler
134
135
 
135
- Mongoid.logger = SemanticLogger[Mongoid]
136
- Mongo::Logger.logger = SemanticLogger[Mongo]
136
+ ::Mongoid.logger = SemanticLogger[::Mongoid]
137
+ ::Mongo::Logger.logger = SemanticLogger[::Mongo]
137
138
  end
138
139
 
139
140
  # Eager load files in jobs folder
@@ -0,0 +1,13 @@
1
+ require 'mongoid/factory'
2
+
3
+ module RocketJob
4
+ module MongoidFactory
5
+ def from_db(*args)
6
+ super(*args)
7
+ rescue NameError => exc
8
+ RocketJob::Job.instantiate(attributes, selected_fields)
9
+ end
10
+ end
11
+ end
12
+
13
+ ::Mongoid::Factory.include(RocketJob::MongoidFactory)
@@ -1,5 +1,6 @@
1
1
  require 'csv'
2
2
  require 'yaml'
3
+ require 'optparse'
3
4
  module RocketJob
4
5
  class Performance
5
6
  attr_accessor :count, :servers, :workers, :version, :ruby, :environment, :mongo_config
@@ -45,7 +45,7 @@ module RocketJob
45
45
  field :collect_output, type: Boolean, default: false, class_attribute: true
46
46
 
47
47
  # Run this job no earlier than this time
48
- field :run_at, type: Time
48
+ field :run_at, type: Time, user_editable: true
49
49
 
50
50
  # If a job has not started by this time, destroy it
51
51
  field :expires_at, type: Time, copy_on_restart: true
@@ -245,6 +245,22 @@ module RocketJob
245
245
  queued? && run_at.present? && (run_at > Time.now)
246
246
  end
247
247
 
248
+ # Return [true|false] whether this job is sleeping.
249
+ # I.e. No workers currently working on this job even if it is running.
250
+ def sleeping?
251
+ running? && (worker_count == 0)
252
+ end
253
+
254
+ # Returns [Integer] the number of workers currently working on this job.
255
+ def worker_count
256
+ running? && worker_name.present? ? 1 : 0
257
+ end
258
+
259
+ # Returns [Array<String>] names of workers currently working this job.
260
+ def worker_names
261
+ running? && worker_name.present? ? [worker_name] : []
262
+ end
263
+
248
264
  # Returns [Hash] status of this job
249
265
  def as_json
250
266
  attrs = serializable_hash(methods: [:seconds, :duration])
@@ -1,3 +1,3 @@
1
1
  module RocketJob #:nodoc
2
- VERSION = '3.4.0'
2
+ VERSION = '3.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-13 00:00:00.000000000 Z
11
+ date: 2017-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -84,6 +84,7 @@ files:
84
84
  - lib/rocket_job/config.rb
85
85
  - lib/rocket_job/dirmon_entry.rb
86
86
  - lib/rocket_job/extensions/mongo/logging.rb
87
+ - lib/rocket_job/extensions/mongoid/factory.rb
87
88
  - lib/rocket_job/extensions/rocket_job_adapter.rb
88
89
  - lib/rocket_job/heartbeat.rb
89
90
  - lib/rocket_job/job.rb