Created
February 4, 2013 22:30
-
-
Save anonymous/4710343 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
#!/usr/bin/env ruby | |
if ! %w[ worker launcher ].include?(ARGV.first) | |
puts | |
puts "run me with" | |
puts | |
puts " ruby #{$0} worker # to run a worker" | |
puts | |
puts " ruby #{$0} launch # to launch a sample flow" | |
puts | |
exit 1 | |
end | |
require 'rubygems' | |
require 'json' | |
require 'ruote' | |
require 'ruote-sequel' | |
sequel = | |
Sequel.connect( | |
:adapter => 'mysql', | |
:user => 'root', | |
:password => '', | |
:socket => '/tmp/mysql.sock', | |
:database => 'ruote_test', | |
:after_connect => proc { |c| c.send(:reconnect=, true) }) | |
storage = Ruote::Sequel::Storage.new(sequel) | |
if ARGV.first == 'worker' | |
class Reporter < Ruote::Participant | |
def on_workitem | |
puts "hello #{workitem.fei.sid}" | |
reply | |
end | |
end | |
ruote = Ruote::Dashboard.new(Ruote::Worker.new(storage)) | |
ruote.register('reporter', Reporter) | |
puts "ruote worker running, pid is #{$$}" | |
ruote.join | |
# doesn't exit on its own | |
else | |
ruote = Ruote::Dashboard.new(storage) | |
pdef = | |
Ruote.define do | |
reporter | |
reporter | |
reporter | |
end | |
wfid = ruote.launch(pdef) | |
puts "launched flow instanced #{wfid}" | |
# exits immediately | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment