Skip to content

Instantly share code, notes, and snippets.

@randomcamel
Last active December 11, 2015 14:48
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 randomcamel/4616079 to your computer and use it in GitHub Desktop.
Save randomcamel/4616079 to your computer and use it in GitHub Desktop.
Trying to separate out the process that submits jobs from the process that executes them. Under 1.8.7, the Worker doesn't pick up the job submitted by the 'run' case: the join() command just waits.
require 'rubygems'
require 'ruote' # 2.3.0.2
require 'ruote/storage/fs_storage'
def get_storage
Ruote::FsStorage.new("ruote_issue_work")
end
class MyParticipant < Ruote::Participant
def on_workitem
puts "#{self.class} pid=#{$$} saw workitem for #{workitem.participant_name}, workflow_type=#{f.workflow_type}"
reply
end
end
def launch
ruote = Ruote::Dashboard.new( get_storage )
ruote.noisy = (ENV['NOISY'] == 'true')
ruote.register do
participant 'alpha', MyParticipant
catchall MyParticipant
end
pdef =
Ruote.define do
alpha
bravo
end
wfid = ruote.launch(pdef)
puts "submitted #{wfid}"
ruote.join
end
case ARGV[0]
when "run"
ruote = Ruote::Dashboard.new(Ruote::Worker.new( get_storage ))
puts "waiting for task to complete"
ruote.join
puts "exiting worker"
exit!
when "launch"
launch
puts "exiting Dashboard/launch command"
exit!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment