Printing to Screen in a Rake Task

Printing to screen in a rake task

STDOUT.sync = true

verbose rakefile - print all executed command lines to stdout

rake --trace will probably give you everything you need

Rails how to run rake task

You can run Rake tasks from your shell by running:

rake task_name

To run from from Ruby (e.g., in the Rails console or another Rake task):

Rake::Task['task_name'].invoke

To run multiple tasks in the same namespace with a single task, create the following new task in your namespace:

task :runall => [:iqmedier, :euroads, :mikkelsen, :orville] do
# This will run after all those tasks have run
end

How to get PID of current rake task?

You get the current PID in Ruby with Process.pid

Can I catch errors and continue to next Rake task?

Rake is just Ruby, so you can use Ruby's error handling feature.

namespace :test do
task :migrate do
begin
Rake::Task['A:migrate'].invoke
rescue => e
log(e)
end
Rake::Task['B:migrate'].invoke
end
end


Related Topics



Leave a reply



Submit