examples/sandwich_client.rb in cloudist-0.1.2 vs examples/sandwich_client.rb in cloudist-0.2.0
- old
+ new
@@ -16,28 +16,42 @@
Cloudist.signal_trap!
Cloudist.start {
log.info("Dispatching sandwich making job...")
- enqueue('make.sandwich', {:bread => 'white'})
- # enqueue('make.sandwich', {:bread => 'brown'})
+ unless ARGV.empty?
+ job_count = ARGV.pop.to_i
+ job_count.times { |i| enqueue('make.sandwich', {:bread => 'white', :sandwich_number => i})}
+ end
+
+
+ # enqueue('eat.sandwich', {:sandwich => job.id})
+ # enqueue('make.sandwich', {:bread => 'brown'})
+
# Listen to all sandwich jobs
- listen('make.sandwich') {
+ listen('make.sandwich', 'eat.sandwich') {
everything {
- Cloudist.log.info("Job ID: #{job_id}")
+ Cloudist.log.info("#{headers[:message_type]} - Job ID: #{job_id}")
}
+ error { |e|
+ Cloudist.log.error(e.inspect)
+ Cloudist.log.error(e.backtrace.inspect)
+ Cloudist.stop
+ }
+
progress {
Cloudist.log.info("Progress: #{data[:progress]}")
}
event('started') {
Cloudist.log.info("Started making sandwich at #{Time.now.to_s}")
}
event('finished'){
Cloudist.log.info("Finished making sandwich at #{Time.now.to_s}")
+ Cloudist.stop
}
}
}