Class: Gush::CLI
- Inherits:
-
Thor
- Object
- Thor
- Gush::CLI
- Defined in:
- lib/gush/cli.rb,
lib/gush/cli/overview.rb
Defined Under Namespace
Classes: Overview
Instance Method Summary collapse
- #clear ⇒ Object
- #create(name) ⇒ Object
- #create_and_start(name, *args) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #list ⇒ Object
- #rm(workflow_id) ⇒ Object
- #show(workflow_id) ⇒ Object
- #start(*args) ⇒ Object
- #stop(*args) ⇒ Object
- #viz(name) ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gush/cli.rb', line 18 def initialize(*) super Gush.configure do |config| config.gushfile = .fetch("gushfile", config.gushfile) config.concurrency = .fetch("concurrency", config.concurrency) config.redis_url = .fetch("redis", config.redis_url) #config.namespace = options.fetch("namespace", config.namespace) config.redis_prefix = .fetch('redis_prefix', config.redis_prefix) config.sidekiq_queue = .fetch('sidekiq_queue', config.sidekiq_queue) config.environment = .fetch("environment", config.environment) end load_gushfile end |
Instance Method Details
#clear ⇒ Object
62 63 64 65 |
# File 'lib/gush/cli.rb', line 62 def clear #Sidekiq::Queue.new(client.configuration.namespace).clear Sidekiq::Queue.new(client.configuration.sidekiq_queue).clear end |
#create(name) ⇒ Object
35 36 37 38 39 |
# File 'lib/gush/cli.rb', line 35 def create(name) workflow = client.create_workflow(name) puts "Workflow created with id: #{workflow.id}" puts "Start it with command: gush start #{workflow.id}" end |
#create_and_start(name, *args) ⇒ Object
49 50 51 52 53 |
# File 'lib/gush/cli.rb', line 49 def create_and_start(name, *args) workflow = client.create_workflow(name) client.start_workflow(workflow.id, args) puts "Created and started workflow with id: #{workflow.id}" end |
#list ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gush/cli.rb', line 86 def list workflows = client.all_workflows rows = workflows.map do |workflow| [workflow.id, workflow.class, {alignment: :center, value: status_for(workflow)}] end headers = [ {alignment: :center, value: 'id'}, {alignment: :center, value: 'name'}, {alignment: :center, value: 'status'} ] puts Terminal::Table.new(headings: headers, rows: rows) end |
#rm(workflow_id) ⇒ Object
80 81 82 83 |
# File 'lib/gush/cli.rb', line 80 def rm(workflow_id) workflow = client.find_workflow(workflow_id) client.destroy_workflow(workflow) end |
#show(workflow_id) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/gush/cli.rb', line 71 def show(workflow_id) workflow = client.find_workflow(workflow_id) display_overview_for(workflow) unless [:skip_overview] display_jobs_list_for(workflow, [:jobs]) unless [:skip_jobs] end |
#start(*args) ⇒ Object
42 43 44 45 46 |
# File 'lib/gush/cli.rb', line 42 def start(*args) id = args.shift workflow = client.find_workflow(id) client.start_workflow(workflow, args) end |
#stop(*args) ⇒ Object
56 57 58 59 |
# File 'lib/gush/cli.rb', line 56 def stop(*args) id = args.shift client.stop_workflow(id) end |
#viz(name) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/gush/cli.rb', line 115 def viz(name) client workflow = name.constantize.new graph = Graph.new(workflow) graph.viz Launchy.open graph.path end |
#workers ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/gush/cli.rb', line 100 def workers config = client.configuration #puts "****** gush config cli: #{config.to_hash}" #cmd = " RUN sidekiq" # = config. || '' cmd = "bundle exec sidekiq -r #{config.gushfile} -c #{config.concurrency} -q #{config.sidekiq_queue} -e #{config.environment} #{} -v" puts "#{cmd}" Kernel.exec cmd end |