Learn how to use daemons with your ruby based application like Ruby on Rails. See how it compares to other queueing systems like Queue Classic, Sidekiq, or Delayed Job.
3. GAMEhud
HTTPAPI accepts event and player based
data from game clients.
Incoming data needs to be distributed
between 10-20 tables.
Don’t want to do that in the request.
Need to do background processing!
12. Daemons
Converts a script into a daemon
Not a queue system
A way to create a worker process
13. What is a daemon?
A computer program that runs as a
background process
Daemon processes typically end in ‘d’
For example: sshd
14. Setting up a daemon
Install daemons gem
Create a control file
event_worker_control.rb
Create a loop in the script called by the control file
event_worker.rb
15. Create a control file
require 'rubygems'
require 'bundler/setup'
require 'daemons'
Daemons.run('lib/daemons/event_worker.rb')
16. Loop in your script
$: << File.expand_path(".", File.dirname(__FILE__))
require ‘event_processor'
event_processor = EventProcessor.new
loop do
event_processor.process
sleep(5)
end
17. Control your daemon
ruby daemon-name_control.rb start
ruby daemon-name_control.rb restart
ruby daemon-name_control.rb stop
ruby lib/daemons/event_worker_control.rb
start -- production
PID file