Skip to content

Instantly share code, notes, and snippets.

@curt
Created February 9, 2010 14:49
Show Gist options
  • Save curt/299264 to your computer and use it in GitHub Desktop.
Save curt/299264 to your computer and use it in GitHub Desktop.
Daemonize background process in Rails
#!/usr/bin/env ruby
#
# Usage: ruby background_control.rb [start|stop|restart]
#
require 'rubygems'
require 'daemons'
background_file = File.join(File.dirname(__FILE__), 'lib', 'background.rb')
pid_directory = File.join(File.dirname(__FILE__), 'tmp', 'pids')
Daemons.run(background_file, { :app_name => 'background', :dir_mode => :normal, :dir => pid_directory, :backtrace => true })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment