lib/rocket_job/cli.rb in rocketjob-3.0.0 vs lib/rocket_job/cli.rb in rocketjob-3.0.1
- old
+ new
@@ -68,10 +68,11 @@
if Rails.configuration.eager_load
logger.measure_info('Eager loaded Rails and all Engines') do
Rails.application.eager_load!
Rails::Engine.subclasses.each(&:eager_load!)
+ self.class.eager_load_jobs(File.expand_path('jobs', File.dirname(__FILE__)))
end
end
end
# In a standalone environment, explicitly load config files
@@ -94,10 +95,11 @@
path.dirname.mkpath
SemanticLogger.add_appender(file_name: path.to_s, formatter: :color)
logger.info "Rails not detected. Running standalone: #{environment}"
RocketJob::Config.load!(environment, mongo_config, symmetric_encryption_config)
+ self.class.eager_load_jobs(File.expand_path('jobs', File.dirname(__FILE__)))
self.class.eager_load_jobs
end
# Create a PID file if requested
def write_pidfile
@@ -134,10 +136,10 @@
# Eager load files in jobs folder
def self.eager_load_jobs(path = 'jobs')
Pathname.glob("#{path}/**/*.rb").each do |path|
next if path.directory?
logger.debug "Loading #{path.to_s}"
- load path.expand_path.to_s
+ require path.expand_path.to_s
end
end
# Parse command line options placing results in the corresponding instance variables
def parse(argv)