lib/wayfarer/cli/job.rb in wayfarer-0.4.3 vs lib/wayfarer/cli/job.rb in wayfarer-0.4.4

- old
+ new

@@ -9,28 +9,26 @@ option :batch, type: :string, default: SecureRandom.uuid def perform(job, url) load_environment mock_redis if options[:mock_redis] - url = Addressable::URI.parse(url) job = job.classify.constantize.new task = Wayfarer::Task.new(url, options[:batch]) job.arguments.push(task) job.perform(task) - GC.new(job).run + task.gc.run end desc "enqueue JOB URL", "Enqueue JOB with URL" option :batch, type: :string, default: SecureRandom.uuid def enqueue(job, url) load_environment - mock_redis if options[:mock_redis] + mock_redis if options[:mock_redis] # TODO: Remove, does not belong here - url = Addressable::URI.parse(url) job = job.classify.constantize - job.crawl_later(url, batch: options[:batch]) + job.crawl(url, batch: options[:batch]) end desc "execute JOB URL", "Execute JOB with async adapter" option :mock_redis, type: :boolean @@ -39,18 +37,16 @@ option :max_threads, type: :numeric, default: 1 def execute(job, url) load_environment mock_redis if options[:mock_redis] - url = Addressable::URI.parse(url) job = job.classify.constantize - job.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new(min_threads: options[:min_threads], max_threads: options[:max_threads]) scheduler = job.queue_adapter.instance_variable_get(:@scheduler) executor = scheduler.instance_variable_get(:@async_executor) - job.crawl_later(url, batch: options[:batch]) + job.crawl(url, batch: options[:batch]) sleep(1) while executor.scheduled_task_count > executor.completed_task_count free_agent_pool end