Skip to content

Commit

Permalink
Merge pull request #23 from opscode/ryan/fire_and_forget
Browse files Browse the repository at this point in the history
Add --no-wait option to asynchronously start multiple jobs
  • Loading branch information
jkeiser committed Sep 8, 2014
2 parents 6329f72 + 3876dd0 commit 65f4508
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ The maximum amount of time (in seconds) by which a job must complete, before it
The minimum number of nodes that match the search criteria, are available, and acknowledge the job request. This can be expressed as a
percentage (e.g. 50%) or as an absolute number of nodes (e.g. 145). Default value: 100%

-b --no-wait

Exit immediately after starting a job instead of waiting for it to complete.

== Examples
For example, to search for nodes assigned the role “webapp”, and where 90% of those nodes must be available, enter:

Expand Down
1 change: 1 addition & 0 deletions knife-push.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
# s.add_dependency "mixlib-cli", ">= 1.2.2"

s.add_dependency 'chef', '>= 11.10.4'
s.add_development_dependency 'rspec'
s.require_path = 'lib'
s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
end
8 changes: 8 additions & 0 deletions lib/chef/knife/job_start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class JobStart < Chef::Knife
:required => false,
:description => 'Solr query for list of job candidates.'

option :nowait,
:long => '--no-wait',
:short => '-b',
:boolean => true,
:default => false,
:description => "Rather than waiting for each job to complete, exit immediately after starting the job."

def run
@node_names = []

Expand Down Expand Up @@ -85,6 +92,7 @@ def run
result = rest.post_rest('pushy/jobs', job_json)
job_uri = result['uri']
puts "Started. Job ID: #{job_uri[-32,32]}"
exit(0) if config[:nowait]
previous_state = "Initialized."
begin
sleep(0.1)
Expand Down

0 comments on commit 65f4508

Please sign in to comment.