19. 【寄り道】 Warden Protocol
Wardenに対する各種命令
• ping • run
• create • info
• stop • LimitDisk
• spawn • LimitMemory
• link • net_in
• stream • net_out
コマンドラインコマンドとほぼ同等
ping - ping warden
create [OPTION OPTION ...] - create container, optionally pass options.
destroy <handle> - shutdown container <handle>
stop <handle> - stop all processes in <handle>
spawn <handle> cmd - spawns cmd inside container <handle>, returns #jobid
link <handle> #jobid - do blocking read on results from #jobid
stream <handle> #jobid - do blocking stream on results from #jobid
run <handle> cmd - short hand for stream(spawn(cmd)) i.e. spawns cmd, streams the result
list - list containers
info <handle> - show metadata for container <handle>
limit <handle> mem [<value>] - set or get the memory limit for the container (in bytes)
net <handle> #in - forward port #in on external interface to container <handle>
net <handle> #out <address[/mask][:port]> - allow traffic from the container <handle> to address
<address>
2012-09-13 NTT Software Innovation Center 19
20. 【寄り道】 EM::Warden::FiberAwareClient
/em-warden-client/lib/em/warden/client.rb
– create()メソッドは存在しない
• method_missing()からcall()が呼ばれる
def call(*args, &blk)
…
f = Fiber.current
@connection.call(*args) {|res| f.resume(res) }
result = Fiber.yield
result.get EventMachine::Warden::Client::Connection
end
def method_missing(method, *args, &blk)
call(method, *args, &blk)
end
2012-09-13 NTT Software Innovation Center 20
21. 【寄り道】 EM::Warden::FiberAwareClient
/em-warden-client/lib/em/warden/client.rb
– create()メソッドは存在しない
• method_missing()からcall()が呼ばれる
def call(*args, &blk)
…
使わなくなりました
f = Fiber.current
@connection.call(*args) {|res| f.resume(res) }
result = Fiber.yield
result.get EventMachine::Warden::Client::Connection
end
def method_missing(method, *args, &blk)
call(method, *args, &blk)
end
2012-09-13 NTT Software Innovation Center 21