Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2013 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5105397 to your computer and use it in GitHub Desktop.
Save anonymous/5105397 to your computer and use it in GitHub Desktop.
# Gemfile
#
# ---8<---
# source :rubygems
#
# gem 'yajl-ruby', :require => 'yajl'
# #gem 'ruote'
# gem 'ruote', :git => 'git://github.com/jmettraux/ruote.git'
# --->8---
require 'ruote'
ruote =
Ruote::Dashboard.new(
Ruote::Worker.new(
Ruote::HashStorage.new))
#
# or
#
# require 'ruote/storage/fs_storage'
#
# ruote =
# Ruote::Dashboard.new(
# Ruote::Worker.new(
# Ruote::FsStorage.new("ruote_issue_work_#{Time.now.to_i}")))
ruote.noisy = (ENV['NOISY'] == 'true')
#
# define participant classes (if needed)
#
class MyParticipant < Ruote::Participant
def on_workitem
#puts "#{self.class} saw workitem for #{workitem.participant_name}"
#reply
raise "error in participant"
end
end
#
# register participants
#
ruote.register do
participant 'alpha', MyParticipant
catchall MyParticipant
end
#
# define process
#
pdef =
Ruote.define do
alpha
bravo
end
#
# run process
#
wfid = ruote.launch(pdef)
r = ruote.wait_for(wfid)
# exit the ruby process only when process is over or got into an error
if r['action'] == 'error_intercepted'
puts "*** error, the process stopped ***"
p ruote.ps(wfid)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment