Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Created March 20, 2014 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvinsj/9659338 to your computer and use it in GitHub Desktop.
Save alvinsj/9659338 to your computer and use it in GitHub Desktop.
task :my_task => :environment do
File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid } if ENV['PIDFILE']
Model.perform_task!
end
god -c run_rake_task.god -D
God.watch do |w|
w.dir = "#{rails_root}"
w.name = "my_task"
w.interval = 10.seconds
w.pid_file = "#{rails_root}/tmp/pids/#{w.name}.pid"
w.env = {"RAILS_ENV"=>rails_env, 'PIDFILE' => w.pid_file}
w.start = "bundle exec rake my_task &"
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment