简体   繁体   中英

How do I verify if a series of rake tasks ran correctly? Or, what alternatives are there to rake

Somebody has asked a similar question here:

https://github.com/jimweirich/rake/issues/257

The answer from the maintainer was:

I am going to reject this since it allows you to use tasks in non-rake-like ways.

So what are the correct way of using rake if a task depends of other tasks.

task 'succeed' => ['db:drop','stats'] do something end

displays results of stats even if Postgres threw an error and db:drop failded because of active connections.

If rake is not suitable for system maintenace, what tools should I use? I need to be able to run a backup of a database, then do some tests, then drop the database and finally restore from backup.

to hel you understand my problem look at folowing fragment

namespace :experiment do
  desc "TODO"
  task 'succeed' => ['stopme', 'stats'] do
    puts 'this and stats task should not run'
  end

  desc "TODO"
  task stopme: :environment do
    Rake::Task['db:drop'].invoke
  end
end

You can invoke tasks manually like that:

task :stats => :environment do
  Rake::Task['db:drop'].invoke rescue nil
  # do something
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM