Book Image

Rake Task Management Essentials

By : Andrey Koleshko
Book Image

Rake Task Management Essentials

By: Andrey Koleshko

Overview of this book

Table of Contents (18 chapters)
Rake Task Management Essentials
About the Author
About the Reviewers

Defining tasks with parallel prerequisites

Describing rake tasks that depend on other tasks that should be executed in parallel is actually a straightforward, solvable problem. Just define your tasks with a multitask method instead of the task method, as shown in the following code snippet, and that's it:

multitask :setup => [:install_ruby, :install_nginx, :install_rails] do
  puts "The build is completed"

In this example, the tasks install_ruby, install_nginx, and install_rails will be executed in parallel before the action of the setup task. This means that for each dependent task, a Ruby thread will be created and they will be run at the same time. The setup task will wait for the threads until they are finished.

Check out the following Rakefile that will be used to verify the previously mentioned statements:

task :task1 do
  puts 'Action of task 1'

task :task2 do
  puts 'Action of task 2'

multitask :task3 => [:task1, :task2] do
  puts 'Action of task 3'

Now, open the...