Skip to content

Instantly share code, notes, and snippets.

/ypz0.rb

Created Feb 4, 2013
Embed
What would you like to do?
#!/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
You can’t perform that action at this time.