Skip to content

Instantly share code, notes, and snippets.

@nofxx
Created September 12, 2009 10:01
Show Gist options
  • Save nofxx/185784 to your computer and use it in GitHub Desktop.
Save nofxx/185784 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rubygems"
require "nanite"
puts "[XMAPPER] Starting mapper!"
pid = fork do
# $stdin.close
# $stdout.close
# $stderr.close
Signal.trap('HUP', 'IGNORE') # Don't die upon logout
EM.run do
# start up a new mapper with a ping time of 10 seconds
Nanite.start_mapper(:host => 'localhost', :user => 'mapper', :pass => 'testing', :vhost => '/nanite', :log_level => 'info', :requests_failsafe => true)
EM.add_periodic_timer(300) do
puts "[RUN] Dispatching check 5 min.."
Nanite.push("/expire/check", "console")
end
EM.add_periodic_timer(30) do
puts "[RUN] Dispatching check 30 sec.."
Nanite.push("/expire/check", "console")
end
end
end
# Save a pid file and exit
if pid
pid_file = File.join(File.dirname(__FILE__), "..", "tmp", "pids", "rmapper.pid")
File.open(pid_file, "w") { |f| f.write pid }
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment