Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Created January 14, 2010 14:49
Show Gist options
  • Save lukeredpath/277216 to your computer and use it in GitHub Desktop.
Save lukeredpath/277216 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# if you have lib/scripts/do_something.rb
# you might run:
# script/runner lib/scripts/do_something.rb
# but now you can do:
# script/daemon lib/scripts/do_something.rb (run|start|stop|restart)
require File.join(File.dirname(__FILE__), *%w[.. config environment])
require 'daemons'
script = ARGV.shift
Daemons.run(script, :dir_mode => :normal, :dir => Rails.root + "tmp/pids")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment