Created
March 7, 2013 03:32
-
-
Save anonymous/5105397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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