capfile syntax help

59 views
Skip to first unread message

Robin Bowes

unread,
Nov 19, 2009, 11:28:08 AM11/19/09
to capis...@googlegroups.com
Hi,

I've got the following block in my capfile:

# Custom tasks for our hosting environment.
namespace :remote do

desc <<-DESC
Create directory required by copy_remote_dir.
DESC
task :create_copy_remote_dir, :roles => :web do
print " creating #{copy_remote_dir}.\n"
run "mkdir -p #{copy_remote_dir}"
end

end

I want to add a task that restarts some services post-deploy. It will be
something like:

desc <<-DESC
Restart services on remote node
DESC
task :restart_services, :roles => :web do
print " restarting services.\n"
run "sv restart send_*"
end

My question: where do I put that?

Does it just go in the "namespace :remote block? ie:

# Custom tasks for our hosting environment.
namespace :remote do

desc <<-DESC
Create directory required by copy_remote_dir.
DESC
task :create_copy_remote_dir, :roles => :web do
print " creating #{copy_remote_dir}.\n"
run "mkdir -p #{copy_remote_dir}"
end

desc <<-DESC
Restart services on remote node
DESC
task :restart_services, :roles => :web do
print " restarting services.\n"
run "sv restart send_*"
end

end

R.

Nick Howard

unread,
Nov 19, 2009, 12:52:10 PM11/19/09
to capis...@googlegroups.com
I don't think it matters too much where you put it. Just add it
somewhere that makes sense.
Then to have it run automatically after deploy you just add an after
call somewhere in the body of your recipe file. So if you were to name
it :restart_services and put it in the :remote namespace, you could do
something like this:

after "deploy:update_code","remote:restart_services"

http://www.capify.org/index.php/Frequently_Asked_Questions#How_do_I_.22hook.22_in_my_methods_to_run_before_or_after_standard_deployment_tasks.3F


--
-Nick Howard
http://blog.baroquebobcat.com/
Reply all
Reply to author
Forward
0 new messages