Skip to content

Instantly share code, notes, and snippets.

@jeremyd
Created November 18, 2012 04:00
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 jeremyd/4103428 to your computer and use it in GitHub Desktop.
Save jeremyd/4103428 to your computer and use it in GitHub Desktop.
DCell actor
require 'dcell'
supervisor = DCell.start :id => "dispatch", :addr => "tcp://127.0.0.1:4001", :directory => {:id => "node1", :addr => "tcp://127.0.0.1:4000"}
node = DCell::Node["node1"]
builder = node[:builder]
while !builder.available
sleep 1
end
builder.create_image
# Shutdown cleanly?
Celluloid::Actor.all.each do |actor|
actor.future(:terminate)
end
sleep 5
exit 0
~/recent_projects/ami-agents/lib(master ✗) ruby dispatcher.rb
I, [2012-11-17T19:57:41.762520 #13950] INFO -- : Connected to node1
I, [2012-11-17T19:57:41.763153 #13950] INFO -- : Connected to dispatch
W, [2012-11-17T19:57:41.801029 #13950] WARN -- : DCell::InfoService is crashing on initialize too quickly, sleeping for 30 seconds
W, [2012-11-17T19:57:41.803323 #13950] WARN -- : DCell::Server is crashing on initialize too quickly, sleeping for 30 seconds
I, [2012-11-17T19:57:41.804066 #13950] INFO -- : Terminating 4 actors...
I, [2012-11-17T19:57:41.804945 #13950] INFO -- : Shutdown completed cleanly
/usr/lib/ruby/gems/1.9.1/gems/celluloid-0.10.0/lib/celluloid/mailbox.rb:26:in `<<': dead recipient (Celluloid::MailboxError)
from /usr/lib/ruby/gems/1.9.1/gems/celluloid-0.10.0/lib/celluloid/future.rb:35:in `execute'
from /usr/lib/ruby/gems/1.9.1/gems/celluloid-0.10.0/lib/celluloid/actor.rb:71:in `future'
from /usr/lib/ruby/gems/1.9.1/gems/celluloid-0.10.0/lib/celluloid/actor_proxy.rb:52:in `future'
from dispatcher.rb:15:in `block in <main>'
from dispatcher.rb:14:in `each'
from dispatcher.rb:14:in `<main>'
~/recent_projects/ami-agents/lib(master ✗) ruby dispatcher.rb
I, [2012-11-17T19:57:57.164329 #13986] INFO -- : Connected to node1
I, [2012-11-17T19:57:57.164936 #13986] INFO -- : Connected to dispatch
W, [2012-11-17T19:57:57.211167 #13986] WARN -- : DCell::InfoService is crashing on initialize too quickly, sleeping for 30 seconds
W, [2012-11-17T19:57:57.212052 #13986] WARN -- : DCell::Server is crashing on initialize too quickly, sleeping for 30 seconds
W, [2012-11-17T19:57:57.212997 #13986] WARN -- : DCell::NodeManager is crashing on initialize too quickly, sleeping for 30 seconds
W, [2012-11-17T19:57:57.213779 #13986] WARN -- : DCell::NodeManager is crashing on initialize too quickly, sleeping for 30 seconds
I, [2012-11-17T19:58:02.221050 #13986] INFO -- : Terminating 3 actors...
I, [2012-11-17T19:58:02.222341 #13986] INFO -- : Shutdown completed cleanly
~/recent_projects/ami-agents/lib(master ✗)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment