Not all of us have the ability to change the webapps directory into a symlink to the current directory and some might want to host more than one war. It would be nice in the recipe for war deployment if you were to do something like this:
after 'deploy:symlink' do
cmd = "rm -f #{tomcat_home}/webapps/#{war} && ln -s #{deploy_to}/current/#{war} #{tomcat_home}/webapps/#{war}"
puts cmd
run cmd
end
That way it will update the war symlink's modified datetime which will trigger tomcat to redeploy the war (if configured to do that), but more importantly since restarting tomcat would do that anyway, the benefit is that the application owner does not have to bother the sysadmin to have the webapps directory be a symlink to current. In this way you could have a number of current directories, one for each deployment, and just have different war symlinks in the webapps dir.
Hope this helps!
Gary
Having trouble with formatting... here it is again:
after 'deploy:symlink' do
cmd = "rm -f #{tomcat_home}/webapps/#{war} && ln -s #{deploy_to}/current/#{war} #{tomcat_home}/webapps/#{war}"
puts cmd
run cmd
end
Agreed. I adjusted my local scripts to do a similar thing a while back, having run into the same problem when I wanted to deploy more than one war. I'll update the script out here. Thanks for the feedback.
Gary: I just had a moment to look into the posted code, and it seems to already be essentially doing that (see line 74 in http://github.com/andynu/capistrano-recipes/blob/master/capfile_tomcat ). I did just add a -f flag to the symlink which removes the need for the rm, but since current is a symlink i'm don't think it matters if it is after 'deploy:symlink' or after 'deploy:setup'.