examples/sandwich_worker.rb in cloudist-0.0.2 vs examples/sandwich_worker.rb in cloudist-0.0.3
- old
+ new
@@ -1,21 +1,38 @@
+# Cloudst Example: Sandwich Worker
+#
+# This example demonstrates receiving a job and sending back events to the client to let it know we've started and finsihed
+# making a sandwich. From here you could dispatch an eat.sandwich event.
+#
+# Be sure to update the Cloudist connection settings if they differ from defaults:
+# user: guest
+# pass: guest
+# port: 5672
+# host: localhost
+# vhost: /
+#
$:.unshift File.dirname(__FILE__) + '/../lib'
require "rubygems"
require "cloudist"
+ENV['AMQP_URL'] = 'amqp://test_pilot:t35t_p1l0t!@ec2-50-16-8-137.compute-1.amazonaws.com:5672/ivan'
+
Cloudist.signal_trap!
Cloudist.start {
log.info("Started Worker")
worker {
job('make.sandwich') {
# Fire the started event
- started!
log.info("JOB (#{id}) Make sandwich with #{data[:bread]} bread")
log.debug(data.inspect)
- finished!
+ EM.defer {
+ started!
+ sleep(5)
+ finished!
+ }
}
}
}