Created
March 20, 2014 08:11
-
-
Save alvinsj/9659338 to your computer and use it in GitHub Desktop.
monitor rake task with god. ref: http://makandracards.com/makandra/2371-monitor-a-rake-task-with-god
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :my_task => :environment do | |
File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid } if ENV['PIDFILE'] | |
Model.perform_task! | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
god -c run_rake_task.god -D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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