rocketjob 5.1.1 → 5.2.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rocketjob +2 -2
  3. data/bin/rocketjob_batch_perf +1 -1
  4. data/bin/rocketjob_perf +1 -1
  5. data/lib/rocket_job/active_worker.rb +1 -0
  6. data/lib/rocket_job/batch.rb +16 -17
  7. data/lib/rocket_job/batch/callbacks.rb +1 -2
  8. data/lib/rocket_job/batch/io.rb +10 -6
  9. data/lib/rocket_job/batch/logger.rb +2 -2
  10. data/lib/rocket_job/batch/lower_priority.rb +2 -2
  11. data/lib/rocket_job/batch/model.rb +23 -23
  12. data/lib/rocket_job/batch/performance.rb +19 -21
  13. data/lib/rocket_job/batch/result.rb +1 -1
  14. data/lib/rocket_job/batch/results.rb +1 -1
  15. data/lib/rocket_job/batch/state_machine.rb +5 -6
  16. data/lib/rocket_job/batch/statistics.rb +10 -8
  17. data/lib/rocket_job/batch/tabular.rb +2 -2
  18. data/lib/rocket_job/batch/tabular/input.rb +11 -7
  19. data/lib/rocket_job/batch/tabular/output.rb +1 -1
  20. data/lib/rocket_job/batch/throttle.rb +11 -30
  21. data/lib/rocket_job/batch/{throttle_running_slices.rb → throttle_running_workers.rb} +13 -10
  22. data/lib/rocket_job/batch/worker.rb +102 -85
  23. data/lib/rocket_job/cli.rb +57 -54
  24. data/lib/rocket_job/config.rb +8 -10
  25. data/lib/rocket_job/dirmon_entry.rb +13 -10
  26. data/lib/rocket_job/event.rb +16 -16
  27. data/lib/rocket_job/extensions/mongo/logging.rb +2 -2
  28. data/lib/rocket_job/extensions/mongoid/clients/options.rb +2 -2
  29. data/lib/rocket_job/extensions/mongoid/contextual/mongo.rb +4 -2
  30. data/lib/rocket_job/extensions/mongoid/factory.rb +13 -5
  31. data/lib/rocket_job/extensions/rocket_job_adapter.rb +2 -1
  32. data/lib/rocket_job/job_exception.rb +0 -3
  33. data/lib/rocket_job/jobs/dirmon_job.rb +4 -4
  34. data/lib/rocket_job/jobs/housekeeping_job.rb +7 -7
  35. data/lib/rocket_job/jobs/on_demand_batch_job.rb +14 -4
  36. data/lib/rocket_job/jobs/on_demand_job.rb +3 -3
  37. data/lib/rocket_job/jobs/performance_job.rb +1 -1
  38. data/lib/rocket_job/jobs/re_encrypt/relational_job.rb +11 -10
  39. data/lib/rocket_job/jobs/upload_file_job.rb +9 -5
  40. data/lib/rocket_job/performance.rb +24 -22
  41. data/lib/rocket_job/plugins/cron.rb +7 -3
  42. data/lib/rocket_job/plugins/document.rb +7 -5
  43. data/lib/rocket_job/plugins/job/callbacks.rb +1 -1
  44. data/lib/rocket_job/plugins/job/logger.rb +3 -3
  45. data/lib/rocket_job/plugins/job/model.rb +34 -27
  46. data/lib/rocket_job/plugins/job/persistence.rb +7 -34
  47. data/lib/rocket_job/plugins/job/state_machine.rb +5 -4
  48. data/lib/rocket_job/plugins/job/throttle.rb +12 -28
  49. data/lib/rocket_job/plugins/job/throttle_running_jobs.rb +2 -2
  50. data/lib/rocket_job/plugins/job/worker.rb +22 -70
  51. data/lib/rocket_job/plugins/processing_window.rb +5 -4
  52. data/lib/rocket_job/plugins/restart.rb +3 -3
  53. data/lib/rocket_job/plugins/retry.rb +2 -2
  54. data/lib/rocket_job/plugins/singleton.rb +1 -2
  55. data/lib/rocket_job/plugins/state_machine.rb +4 -4
  56. data/lib/rocket_job/plugins/transaction.rb +1 -1
  57. data/lib/rocket_job/rocket_job.rb +5 -4
  58. data/lib/rocket_job/server.rb +2 -2
  59. data/lib/rocket_job/server/model.rb +14 -13
  60. data/lib/rocket_job/server/state_machine.rb +1 -2
  61. data/lib/rocket_job/sliced/compressed_slice.rb +4 -4
  62. data/lib/rocket_job/sliced/encrypted_slice.rb +4 -4
  63. data/lib/rocket_job/sliced/input.rb +16 -16
  64. data/lib/rocket_job/sliced/output.rb +2 -2
  65. data/lib/rocket_job/sliced/slice.rb +43 -20
  66. data/lib/rocket_job/sliced/slices.rb +14 -11
  67. data/lib/rocket_job/subscriber.rb +6 -6
  68. data/lib/rocket_job/subscribers/logger.rb +3 -3
  69. data/lib/rocket_job/supervisor.rb +12 -12
  70. data/lib/rocket_job/supervisor/shutdown.rb +7 -7
  71. data/lib/rocket_job/throttle_definition.rb +37 -0
  72. data/lib/rocket_job/throttle_definitions.rb +39 -0
  73. data/lib/rocket_job/version.rb +1 -1
  74. data/lib/rocket_job/worker.rb +116 -34
  75. data/lib/rocket_job/worker_pool.rb +6 -6
  76. data/lib/rocketjob.rb +72 -76
  77. metadata +16 -18
  78. data/lib/rocket_job/extensions/mongoid_5/clients/options.rb +0 -38
  79. data/lib/rocket_job/extensions/mongoid_5/contextual/mongo.rb +0 -64
  80. data/lib/rocket_job/extensions/mongoid_5/factory.rb +0 -13
@@ -1,10 +1,10 @@
1
- require 'mongo/monitoring/command_log_subscriber'
1
+ require "mongo/monitoring/command_log_subscriber"
2
2
 
3
3
  module Mongo
4
4
  class Monitoring
5
5
  class CommandLogSubscriber
6
6
  include SemanticLogger::Loggable
7
- logger.name = 'Mongo'
7
+ logger.name = "Mongo"
8
8
 
9
9
  def started(event)
10
10
  @event_command = event.command
@@ -1,5 +1,5 @@
1
- require 'mongoid/criteria'
2
- require 'mongoid/document'
1
+ require "mongoid/criteria"
2
+ require "mongoid/document"
3
3
  module RocketJob
4
4
  module MongoidClients
5
5
  module Options
@@ -3,9 +3,11 @@ module Mongoid
3
3
  module Contextual
4
4
  class Mongo
5
5
  def initialize(criteria)
6
- @criteria, @klass, @cache = criteria, criteria.klass, criteria.options[:cache]
6
+ @criteria = criteria
7
+ @klass = criteria.klass
8
+ @cache = criteria.options[:cache]
7
9
  # Only line changed is here, get collection name from criteria, not @klass
8
- #@collection = @klass.collection
10
+ # @collection = @klass.collection
9
11
  @collection = criteria.collection
10
12
 
11
13
  criteria.send(:merge_type_selection)
@@ -1,12 +1,20 @@
1
- require 'mongoid/factory'
1
+ require "mongoid/factory"
2
2
 
3
3
  module RocketJob
4
4
  # Don't convert to Mongoid::Factory since it conflicts with Mongoid use.
5
5
  module MongoidFactory
6
- def from_db(klass, attributes = nil, criteria = nil)
7
- obj = super(klass, attributes, criteria)
8
- obj.collection_name = criteria.collection_name if criteria
9
- obj
6
+ if Mongoid::VERSION.to_f >= 7.1
7
+ def from_db(klass, attributes = nil, criteria = nil, selected_fields = nil)
8
+ obj = super(klass, attributes, criteria, selected_fields)
9
+ obj.collection_name = criteria.collection_name if criteria
10
+ obj
11
+ end
12
+ else
13
+ def from_db(klass, attributes = nil, criteria = nil)
14
+ obj = super(klass, attributes, criteria)
15
+ obj.collection_name = criteria.collection_name if criteria
16
+ obj
17
+ end
10
18
  end
11
19
  end
12
20
  end
@@ -71,7 +71,7 @@ module ActiveJob
71
71
  end
72
72
 
73
73
  def self.active_job_params(active_job)
74
- params = {
74
+ params = {
75
75
  description: active_job.class.name,
76
76
  data: active_job.serialize,
77
77
  active_job_id: active_job.job_id,
@@ -81,6 +81,7 @@ module ActiveJob
81
81
  params[:priority] = active_job.priority if active_job.respond_to?(:priority) && active_job.priority
82
82
  params
83
83
  end
84
+
84
85
  private_class_method :active_job_params
85
86
  end
86
87
  end
@@ -18,9 +18,6 @@ module RocketJob
18
18
  # Name of the server on which this exception occurred
19
19
  field :worker_name, type: String
20
20
 
21
- # The record within which this exception occurred
22
- field :record_number, type: Integer
23
-
24
21
  # Returns [JobException] built from the supplied exception
25
22
  def self.from_exception(exc, **args)
26
23
  new(
@@ -1,4 +1,4 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
  module RocketJob
3
3
  module Jobs
4
4
  # Dirmon monitors folders for files matching the criteria specified in DirmonEntry
@@ -79,10 +79,10 @@ module RocketJob
79
79
  end
80
80
 
81
81
  # BSON Keys cannot contain periods
82
- key = iopath.to_s.tr('.', '_')
83
- previous_size = previous_file_names[key]
82
+ key = iopath.to_s.tr(".", "_")
83
+ previous_size = previous_file_names[key]
84
84
  # Check every few minutes for a file size change before trying to process the file.
85
- size = check_file(entry, iopath, previous_size)
85
+ size = check_file(entry, iopath, previous_size)
86
86
  new_file_names[key] = size if size
87
87
  end
88
88
  end
@@ -30,9 +30,9 @@ module RocketJob
30
30
  include RocketJob::Plugins::Singleton
31
31
 
32
32
  self.priority = 25
33
- self.description = 'Cleans out historical jobs, and zombie servers.'
33
+ self.description = "Cleans out historical jobs, and zombie servers."
34
34
  # Runs every 15 minutes
35
- self.cron_schedule = '*/15 * * * * UTC'
35
+ self.cron_schedule = "*/15 * * * * UTC"
36
36
 
37
37
  # Whether to destroy zombie servers automatically
38
38
  field :destroy_zombies, type: Boolean, default: true, user_editable: true, copy_on_restart: true
@@ -46,13 +46,13 @@ module RocketJob
46
46
  field :queued_retention, type: Integer, user_editable: true, copy_on_restart: true
47
47
 
48
48
  def perform
49
- RocketJob::Job.aborted.where(completed_at: {'$lte' => aborted_retention.seconds.ago}).destroy_all if aborted_retention
49
+ RocketJob::Job.aborted.where(completed_at: {"$lte" => aborted_retention.seconds.ago}).destroy_all if aborted_retention
50
50
  if completed_retention
51
- RocketJob::Job.completed.where(completed_at: {'$lte' => completed_retention.seconds.ago}).destroy_all
51
+ RocketJob::Job.completed.where(completed_at: {"$lte" => completed_retention.seconds.ago}).destroy_all
52
52
  end
53
- RocketJob::Job.failed.where(completed_at: {'$lte' => failed_retention.seconds.ago}).destroy_all if failed_retention
54
- RocketJob::Job.paused.where(completed_at: {'$lte' => paused_retention.seconds.ago}).destroy_all if paused_retention
55
- RocketJob::Job.queued.where(created_at: {'$lte' => queued_retention.seconds.ago}).destroy_all if queued_retention
53
+ RocketJob::Job.failed.where(completed_at: {"$lte" => failed_retention.seconds.ago}).destroy_all if failed_retention
54
+ RocketJob::Job.paused.where(completed_at: {"$lte" => paused_retention.seconds.ago}).destroy_all if paused_retention
55
+ RocketJob::Job.queued.where(created_at: {"$lte" => queued_retention.seconds.ago}).destroy_all if queued_retention
56
56
 
57
57
  if destroy_zombies
58
58
  # Cleanup zombie servers
@@ -32,8 +32,15 @@
32
32
  # job.cleanup!
33
33
  #
34
34
  # By default output is not collected, add the option `collect_output: true` to collect output.
35
+ #
35
36
  # Example:
36
- # job = RocketJob::Jobs::OnDemandBatchJob(description: 'Fix data', code: code, throttle_running_slices: 5, priority: 30, collect_output: true)
37
+ # job = RocketJob::Jobs::OnDemandBatchJob(
38
+ # description: 'Fix data',
39
+ # code: code,
40
+ # throttle_running_workers: 5,
41
+ # priority: 30,
42
+ # collect_output: true
43
+ # )
37
44
  #
38
45
  # Example: Move the upload operation into a before_batch.
39
46
  # upload_code = <<-CODE
@@ -61,7 +68,7 @@ module RocketJob
61
68
  include RocketJob::Batch::Statistics
62
69
 
63
70
  self.priority = 90
64
- self.description = 'Batch Job'
71
+ self.description = "Batch Job"
65
72
  self.destroy_on_complete = false
66
73
 
67
74
  # Code that is performed against every row / record.
@@ -104,23 +111,26 @@ module RocketJob
104
111
 
105
112
  def validate_code
106
113
  return if code.nil?
114
+
107
115
  validate_field(:code) { load_perform_code }
108
116
  end
109
117
 
110
118
  def validate_before_code
111
119
  return if before_code.nil?
120
+
112
121
  validate_field(:before_code) { instance_eval("def __before_code\n#{before_code}\nend") }
113
122
  end
114
123
 
115
124
  def validate_after_code
116
125
  return if after_code.nil?
126
+
117
127
  validate_field(:after_code) { instance_eval("def __after_code\n#{after_code}\nend") }
118
128
  end
119
129
 
120
130
  def validate_field(field)
121
131
  yield
122
- rescue Exception => exc
123
- errors.add(field, "Failed to load :#{field}, #{exc.inspect}")
132
+ rescue Exception => e
133
+ errors.add(field, "Failed to load :#{field}, #{e.inspect}")
124
134
  end
125
135
  end
126
136
  end
@@ -74,7 +74,7 @@ module RocketJob
74
74
  include RocketJob::Plugins::Cron
75
75
  include RocketJob::Plugins::Retry
76
76
 
77
- self.description = 'On Demand Job'
77
+ self.description = "On Demand Job"
78
78
  self.destroy_on_complete = false
79
79
  self.retry_limit = 0
80
80
 
@@ -95,8 +95,8 @@ module RocketJob
95
95
 
96
96
  def validate_code
97
97
  load_code
98
- rescue Exception => exc
99
- errors.add(:code, "Failed to parse :code, #{exc.inspect}")
98
+ rescue Exception => e
99
+ errors.add(:code, "Failed to parse :code, #{e.inspect}")
100
100
  end
101
101
  end
102
102
  end
@@ -4,7 +4,7 @@ module RocketJob
4
4
  include RocketJob::Batch
5
5
 
6
6
  # Define the job's default attributes
7
- self.description = 'Performance Test'
7
+ self.description = "Performance Test"
8
8
  self.priority = 5
9
9
  self.slice_size = 100
10
10
  self.destroy_on_complete = false
@@ -1,5 +1,5 @@
1
1
  begin
2
- require 'active_record'
2
+ require "active_record"
3
3
  rescue LoadError
4
4
  raise 'RocketJob::Jobs::ReEncrypt::RelationalJob uses ActiveRecord to obtain the database connection, please install the gem "activerecord".'
5
5
  end
@@ -20,12 +20,12 @@ module RocketJob
20
20
  class RelationalJob < RocketJob::Job
21
21
  include RocketJob::Batch
22
22
 
23
- self.slice_size = 1000
24
- self.priority = 30
25
- self.destroy_on_complete = false
26
- self.compress = true
27
- self.throttle_running_jobs = 1
28
- self.throttle_running_slices = 10
23
+ self.slice_size = 1000
24
+ self.priority = 30
25
+ self.destroy_on_complete = false
26
+ self.compress = true
27
+ self.throttle_running_jobs = 1
28
+ self.throttle_running_workers = 10
29
29
 
30
30
  # Name of the table being re-encrypted
31
31
  field :table_name, type: String
@@ -43,7 +43,7 @@ module RocketJob
43
43
  connection.tables.each do |table|
44
44
  columns = connection.columns(table)
45
45
  columns.each do |column|
46
- if column.name.start_with?('encrypted_')
46
+ if column.name.start_with?("encrypted_")
47
47
  add_column = column.name
48
48
  (h[table] ||= []) << add_column if add_column
49
49
  end
@@ -90,7 +90,7 @@ module RocketJob
90
90
  end
91
91
  end
92
92
  if updates.size.positive?
93
- sql << updates.join(', ')
93
+ sql << updates.join(", ")
94
94
  sql << " where id=#{row[1]}"
95
95
  logger.trace sql
96
96
  self.class.connection.execute sql
@@ -114,7 +114,8 @@ module RocketJob
114
114
  end
115
115
 
116
116
  def re_encrypt(encrypted_value)
117
- return encrypted_value if (encrypted_value == '') || encrypted_value.nil?
117
+ return encrypted_value if (encrypted_value == "") || encrypted_value.nil?
118
+
118
119
  SymmetricEncryption.encrypt(SymmetricEncryption.decrypt(encrypted_value))
119
120
  end
120
121
 
@@ -1,5 +1,5 @@
1
- require 'fileutils'
2
- require 'uri'
1
+ require "fileutils"
2
+ require "uri"
3
3
 
4
4
  module RocketJob
5
5
  module Jobs
@@ -40,10 +40,10 @@ module RocketJob
40
40
  job.id = job_id if job_id
41
41
  upload_file(job)
42
42
  job.save!
43
- rescue StandardError => exc
43
+ rescue StandardError => e
44
44
  # Prevent partial uploads
45
45
  job&.cleanup! if job.respond_to?(:cleanup!)
46
- raise(exc)
46
+ raise(e)
47
47
  end
48
48
 
49
49
  private
@@ -74,6 +74,7 @@ module RocketJob
74
74
  def job_is_a_rocket_job
75
75
  klass = job_class
76
76
  return if klass.nil? || klass.ancestors&.include?(RocketJob::Job)
77
+
77
78
  errors.add(:job_class_name, "Model #{job_class_name} must be defined and inherit from RocketJob::Job")
78
79
  end
79
80
 
@@ -83,14 +84,17 @@ module RocketJob
83
84
  def job_implements_upload
84
85
  klass = job_class
85
86
  return if klass.nil? || klass.instance_methods.any? { |m| VALID_INSTANCE_METHODS.include?(m) }
87
+
86
88
  errors.add(:job_class_name, "#{job_class} must implement any one of: :#{VALID_INSTANCE_METHODS.join(' :')} instance methods")
87
89
  end
88
90
 
89
91
  def file_exists
90
92
  return if upload_file_name.nil?
93
+
91
94
  uri = URI.parse(upload_file_name)
92
- return unless uri.scheme.nil? || uri.scheme == 'file'
95
+ return unless uri.scheme.nil? || uri.scheme == "file"
93
96
  return if File.exist?(upload_file_name)
97
+
94
98
  errors.add(:upload_file_name, "Upload file: #{upload_file_name} does not exist.")
95
99
  end
96
100
  end
@@ -1,6 +1,6 @@
1
- require 'csv'
2
- require 'yaml'
3
- require 'optparse'
1
+ require "csv"
2
+ require "yaml"
3
+ require "optparse"
4
4
  module RocketJob
5
5
  class Performance
6
6
  attr_accessor :count, :servers, :workers, :version, :ruby, :environment, :mongo_config
@@ -11,20 +11,20 @@ module RocketJob
11
11
  @count = 100_000
12
12
  @servers = 0
13
13
  @workers = 0
14
- @environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
15
- @mongo_config = 'config/mongoid.yml'
14
+ @environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
15
+ @mongo_config = "config/mongoid.yml"
16
16
  end
17
17
 
18
18
  # Loads the queue with jobs to be processed once the queue is loaded.
19
19
  # Retain the first and last job for timings, all others are destroyed on completion.
20
20
  def run_test_case(count = self.count)
21
21
  if RocketJob::Server.where(:state.in => %w[running paused]).count.zero?
22
- raise 'Please start servers before starting the performance test'
22
+ raise "Please start servers before starting the performance test"
23
23
  end
24
24
 
25
25
  count_running_workers
26
26
 
27
- puts 'Waiting for workers to pause'
27
+ puts "Waiting for workers to pause"
28
28
  RocketJob::Server.pause_all
29
29
  RocketJob::Jobs::SimpleJob.delete_all
30
30
 
@@ -36,15 +36,16 @@ module RocketJob
36
36
  end
37
37
  puts "Waiting for #{running} workers"
38
38
  break if running.zero?
39
+
39
40
  sleep 1
40
41
  end
41
42
 
42
- puts 'Enqueuing jobs'
43
+ puts "Enqueuing jobs"
43
44
  first = RocketJob::Jobs::SimpleJob.create!(priority: 1, destroy_on_complete: false)
44
45
  (count - 2).times { RocketJob::Jobs::SimpleJob.create! }
45
46
  last = RocketJob::Jobs::SimpleJob.create!(priority: 100, destroy_on_complete: false)
46
47
 
47
- puts 'Resuming workers'
48
+ puts "Resuming workers"
48
49
  RocketJob::Server.resume_all
49
50
 
50
51
  sleep 3 until last.reload.completed?
@@ -58,7 +59,7 @@ module RocketJob
58
59
 
59
60
  # Export the Results hash to a CSV file
60
61
  def export_results(results)
61
- CSV.open("job_results_#{ruby}_#{servers}s_#{workers}w_v#{version}.csv", 'wb') do |csv|
62
+ CSV.open("job_results_#{ruby}_#{servers}s_#{workers}w_v#{version}.csv", "wb") do |csv|
62
63
  csv << results.first.keys
63
64
  results.each { |result| csv << result.values }
64
65
  end
@@ -66,25 +67,25 @@ module RocketJob
66
67
 
67
68
  # Parse command line options
68
69
  def parse(argv)
69
- parser = OptionParser.new do |o|
70
- o.on('-c',
71
- '--count COUNT',
72
- 'Count of jobs to enqueue') do |arg|
70
+ parser = OptionParser.new do |o|
71
+ o.on("-c",
72
+ "--count COUNT",
73
+ "Count of jobs to enqueue") do |arg|
73
74
  self.count = arg.to_i
74
75
  end
75
- o.on('-m',
76
- '--mongo MONGO_CONFIG_FILE_NAME',
77
- 'Path and filename of config file. Default: config/mongoid.yml') do |arg|
76
+ o.on("-m",
77
+ "--mongo MONGO_CONFIG_FILE_NAME",
78
+ "Path and filename of config file. Default: config/mongoid.yml") do |arg|
78
79
  self.mongo_config = arg
79
80
  end
80
- o.on('-e',
81
- '--environment ENVIRONMENT',
82
- 'The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)') do |arg|
81
+ o.on("-e",
82
+ "--environment ENVIRONMENT",
83
+ "The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)") do |arg|
83
84
  self.environment = arg
84
85
  end
85
86
  end
86
- parser.banner = 'rocketjob_perf <options>'
87
- parser.on_tail '-h', '--help', 'Show help' do
87
+ parser.banner = "rocketjob_perf <options>"
88
+ parser.on_tail "-h", "--help", "Show help" do
88
89
  puts parser
89
90
  exit 1
90
91
  end
@@ -96,6 +97,7 @@ module RocketJob
96
97
  self.workers = 0
97
98
  RocketJob::Server.running.each do |server|
98
99
  next if server.zombie?
100
+
99
101
  self.servers += 1
100
102
  self.workers += server.heartbeat.workers
101
103
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/concern'
1
+ require "active_support/concern"
2
2
 
3
3
  module RocketJob
4
4
  module Plugins
@@ -26,6 +26,7 @@ module RocketJob
26
26
  # Overrides: RocketJob::Plugins::Restart#rocket_job_restart_new_instance
27
27
  def rocket_job_restart_new_instance
28
28
  return unless cron_schedule
29
+
29
30
  super
30
31
  end
31
32
 
@@ -35,6 +36,7 @@ module RocketJob
35
36
  # Overrides: RocketJob::Plugins::Restart#rocket_job_restart_abort
36
37
  def rocket_job_restart_abort
37
38
  return unless cron_schedule
39
+
38
40
  rocket_job_restart_new_instance
39
41
  update_attribute(:cron_schedule, nil)
40
42
  end
@@ -54,14 +56,16 @@ module RocketJob
54
56
 
55
57
  def rocket_job_cron_set_run_at
56
58
  return unless cron_schedule
59
+
57
60
  self.run_at = rocket_job_cron_next_time if cron_schedule_changed? && !run_at_changed?
58
61
  end
59
62
 
60
63
  def rocket_job_cron_valid
61
64
  return unless cron_schedule
65
+
62
66
  RocketJob::Plugins::Rufus::CronLine.new(cron_schedule)
63
- rescue ArgumentError => exc
64
- errors.add(:cron_schedule, exc.message)
67
+ rescue ArgumentError => e
68
+ errors.add(:cron_schedule, e.message)
65
69
  end
66
70
  end
67
71
  end