lib/rocket_job/performance.rb in rocketjob-2.1.3 vs lib/rocket_job/performance.rb in rocketjob-3.0.0.alpha
- old
+ new
@@ -13,35 +13,35 @@
@environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
@mongo_config = 'config/mongo.yml'
end
def run_test_case(count = self.count)
- self.worker_processes = RocketJob::Worker.count
+ self.worker_processes = RocketJob::Server.count
raise 'Please start workers before starting the performance test' if worker_processes == 0
self.worker_processes = 0
self.worker_threads = 0
- RocketJob::Worker.where(state: :running).each do |worker_process|
+ RocketJob::Server.running.each do |worker_process|
unless worker_process.zombie?
self.worker_processes += 1
self.worker_threads += worker_process.heartbeat.current_threads
end
end
puts "Running: #{worker_threads} workers, distributed across #{worker_processes} processes"
puts 'Waiting for workers to pause'
- RocketJob::Worker.pause_all
+ RocketJob::Server.pause_all
RocketJob::Jobs::SimpleJob.delete_all
sleep 15
puts 'Enqueuing jobs'
first = RocketJob::Jobs::SimpleJob.create(priority: 1, destroy_on_complete: false)
(count - 2).times { |i| RocketJob::Jobs::SimpleJob.create! }
last = RocketJob::Jobs::SimpleJob.create(priority: 100, destroy_on_complete: false)
puts 'Resuming workers'
- RocketJob::Worker.resume_all
+ RocketJob::Server.resume_all
while (!last.reload.completed?)
sleep 3
end
@@ -61,10 +61,10 @@
def parse(argv)
parser = OptionParser.new do |o|
o.on('-c', '--count COUNT', 'Count of jobs to enqueue') do |arg|
self.count = arg.to_i
end
- o.on('-m', '--mongo MONGO_CONFIG_FILE_NAME', 'Location of mongo.yml config file') do |arg|
+ o.on('-m', '--mongo MONGO_CONFIG_FILE_NAME', 'Path and filename of config file. Default: config/mongoid.yml') do |arg|
self.mongo_config = arg
end
o.on('-e', '--environment ENVIRONMENT', 'The environment to run the app on (Default: RAILS_ENV || RACK_ENV || development)') do |arg|
self.environment = arg
end