I have an event loop that processes some nginx log files and puts them in MongoDB. The log eater scripts work with ruby ββdaemons. http://daemons.rubyforge.org/
I found it much more reliable than god. It also tracks and restarts your script if it dies. If you want to be notified that the runner is dying, you can use monit to do this.
Here is my demon runner script:
#!/usr/bin/env ruby require 'rubygems' require 'bundler' Bundler.require(:default) Bundler.setup(:default) options = { :app_name => "log_eater", :dir_mode => :system, :multiple => true, :backtrace => true, :monitor => true } Daemons.run(File.join(File.dirname(__FILE__), 'log_eater.rb'), options)
It works for months without leakage or no problem. God had problems with leaks and death. Capistrano can restart this by restarting your script run.
Here is an excerpt from mine for gentoo linux
start() { ebegin "Starting log-eater" cd /ruby/STABLE/quickanalytics `scripts/log_eater_runner.rb start -- /usr/logs/nginx.log` eend $? "Failed to start log-eater" }
- after the start command for any arguments that you want to pass to the script.
Michael papile
source share