cap symlink, why not ../

33 views
Skip to first unread message

jeroen

unread,
Nov 22, 2006, 10:42:52 AM11/22/06
to Capistrano
Hi

I was wondering why capistrano symlinks the current directory from the
the root / and not just ../releases/2006xxxx

Small change but it's more robust I think.

Jeroen

Jamis Buck

unread,
Nov 22, 2006, 11:12:33 AM11/22/06
to capis...@googlegroups.com
No particular reason. Why would the latter be more robust than the
former? I have more trust in absolute paths than relative paths,
generally.

- Jamis

> --~--~---------~--~----~------------~-------~--~----~
> To unsubscribe from this group, send email to capistrano-
> unsub...@googlegroups.com
> For more options, visit this group at http://groups.google.com/
> group/capistrano
> -~----------~----~----~----~------~----~------~--~---
>

Jason Perry

unread,
Nov 22, 2006, 12:56:12 PM11/22/06
to capis...@googlegroups.com
I could see a benefit in, say,if--for some reason--you need to move
the location of your deployment path, the relative symlink would
still work. But then of course if I was doing something like that I
would probably be running deploy tasks again, so It's not much of a
benefit.

Jeroen Houben

unread,
Nov 22, 2006, 1:25:11 PM11/22/06
to capis...@googlegroups.com
Jamis Buck wrote:
> No particular reason. Why would the latter be more robust than the
> former? I have more trust in absolute paths than relative paths, generally.

me too. But if I'm quite positive the relationships between folders are
*very* unlikely to ever change than I will use relative links to make it
more portable.

In this case I have more trust in the fact that the releases folder will
always be in current/../releases than my app's folder staying in the
same place.

I have moved my app's location several times and had to reapply the
symlink. It's no biggy though!

Jeroen

mike

unread,
Nov 23, 2006, 5:52:48 PM11/23/06
to capis...@googlegroups.com
I think one reason for relative paths in symlinks is so they don't break when accessed from different mount points. The root can vary depending on which server is looking at it.

For example if the application is on shared storage as:

/export/webapps/app/appname

and your application servers mount it to:

/var/www/app/appname

the relative symlinks would allow you to navigate the directories on either host.
It would probably make deploying to shared storage easier too.

- Mike

NeilW

unread,
Nov 25, 2006, 2:09:59 AM11/25/06
to Capistrano
It's easy enough to knock up yourself.

A little def like this:

def relative_path (from_str, to_str)
require 'pathname'
Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s
end

and then the update_code task to get you started.

desc <<-DESC
Update all servers with the latest revision of the source code.
This does a checkout and links into the shared directories.
DESC
task :update_code, :except => { :no_release => true} do
on_rollback { delete release_path, :recursive => true }
log_path = File.join(release_path, 'log')
public_path = File.join(release_path, 'public')
system_path = File.join(public_path, 'system')
shared_log = relative_path(release_path, File.join(shared_path,
'log'))
shared_system = relative_path(public_path, File.join(shared_path,
'system'))

source.checkout(self)

delete log_path, :recursive => true
delete system_path, :recursive => true
send(run_method, "ln -nfs #{shared_log} #{log_path}")
send(run_method, "ln -nfs #{shared_system} #{system_path}")

# Remove release cache
@releases = nil
end

Reply all
Reply to author
Forward
0 new messages