Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "Server Side Simulator"
- ⚡ cat mcollective-many-server
- #!/usr/bin/env ruby
- require 'rubygems'
- gem 'stomp', '=1.2.11'
- number_of_servers = ARGV[0] || "1"
- number_of_servers.to_i.times do |server_id|
- fork do
- require 'mcollective'
- include MCollective::RPC
- c = rpcclient("rpcutil")
- connection = MCollective::PluginManager["connector_plugin"].connection
- connection.subscribe('/queue/tive.nodes', {
- "selector" => "mc_identity = 'mini-server#{server_id}.example.com'",
- })
- puts "Server #{server_id} ready to go"
- response = "A-well-a, everybody's heard about the bird. Bird, bird, bird, b-bird's the word"
- while true do
- msg = connection.receive
- puts "#{Time.now.to_f} got #{msg.headers["mc_traceme"]}"
- connection.publish(msg.headers["reply-to"], response)#, { "expiry" => ((Time.now.to_i + 59) * 1000).to_s })
- puts "#{Time.now.to_f} sent response"
- end
- exit
- end
- end
- Process.waitall
- d
Advertisement
Add Comment
Please, Sign In to add comment