Class: Ductr::CLI::Main
- Inherits:
-
Thor
- Object
- Thor
- Ductr::CLI::Main
- Defined in:
- lib/ductr/cli/main.rb
Overview
The main CLI is started when used inside a ductr project folder. It exposes scheduling and monitoring tasks.
Instance Method Summary collapse
Instance Method Details
#perform(job_name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ductr/cli/main.rb', line 16 def perform(job_name) job = job_name.camelize.constantize.new(*[:params]) job.is_a?(Pipeline) ? Store.register_pipeline(job) : Store.register_job(job) return job.perform_now if [:sync] job.enqueue return unless ActiveJob::Base.queue_adapter.is_a? ActiveJob::QueueAdapters::AsyncAdapter sleep(0.1) until Store.all_done? end |
#schedule(*scheduler_names) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ductr/cli/main.rb', line 29 def schedule(*scheduler_names) raise ArgumentError, "You must pass at least one scheduler name" if scheduler_names.empty? scheduler_names.each { |name| name.camelize.constantize.new } Scheduler.start sleep_until_interrupt do Scheduler.stop end end |