Guest User

Untitled

a guest
Sep 25th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. "Server Side Simulator"
  2.  
  3. ⚡ cat mcollective-many-server
  4. #!/usr/bin/env ruby
  5. require 'rubygems'
  6. gem 'stomp', '=1.2.11'
  7.  
  8. number_of_servers = ARGV[0] || "1"
  9.  
  10. number_of_servers.to_i.times do |server_id|
  11. fork do
  12. require 'mcollective'
  13. include MCollective::RPC
  14.  
  15. c = rpcclient("rpcutil")
  16. connection = MCollective::PluginManager["connector_plugin"].connection
  17.  
  18. connection.subscribe('/queue/tive.nodes', {
  19. "selector" => "mc_identity = 'mini-server#{server_id}.example.com'",
  20. })
  21. puts "Server #{server_id} ready to go"
  22.  
  23. response = "A-well-a, everybody's heard about the bird. Bird, bird, bird, b-bird's the word"
  24.  
  25. while true do
  26. msg = connection.receive
  27. puts "#{Time.now.to_f} got #{msg.headers["mc_traceme"]}"
  28. connection.publish(msg.headers["reply-to"], response)#, { "expiry" => ((Time.now.to_i + 59) * 1000).to_s })
  29. puts "#{Time.now.to_f} sent response"
  30. end
  31. exit
  32. end
  33. end
  34.  
  35. Process.waitall
  36.  
  37.  
  38. d
Advertisement
Add Comment
Please, Sign In to add comment