Guest User

Untitled

a guest
Apr 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require "rubygems"
  3. require "nanite"
  4.  
  5. puts "[XMAPPER] Starting mapper!"
  6.  
  7. pid = fork do
  8. # $stdin.close
  9. # $stdout.close
  10. # $stderr.close
  11. Signal.trap('HUP', 'IGNORE') # Don't die upon logout
  12.  
  13. EM.run do
  14. # start up a new mapper with a ping time of 10 seconds
  15. Nanite.start_mapper(:host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info', :requests_failsafe => true)
  16.  
  17. EM.add_periodic_timer(300) do
  18. puts "[RUN] Dispatching check 5 min.."
  19. Nanite.push("/expire/check", "console")
  20. end
  21.  
  22.  
  23. EM.add_periodic_timer(30) do
  24. puts "[RUN] Dispatching check 30 sec.."
  25. Nanite.push("/expire/check", "console")
  26. end
  27.  
  28. end
  29. end
  30.  
  31. # Save a pid file and exit
  32. if pid
  33. pid_file = File.join(File.dirname(__FILE__), "..", "tmp", "pids", "rmapper.pid")
  34. File.open(pid_file, "w") { |f| f.write pid }
  35. exit
  36. end
Add Comment
Please, Sign In to add comment