capistrano-3-rails-template icon indicating copy to clipboard operation
capistrano-3-rails-template copied to clipboard

When compiling assets locally, rsync uses the wrong port

Open danielristic opened this issue 12 years ago • 2 comments

I'm testing deploys on vagrant but it failed during asset precompilation as rsync was using the default 22 port and vagrant is expecting port 2222 by default.

I set this up in the vagrant.rb file I use to define the deploy environment:

server '127.0.0.1:2222', user: 'deploy', roles: %w{web app db}, primary: true

But rsync still used the port 22.

So I directly modified the code in compile_assets_locally.cap to

execute"rsync -e 'ssh -p2222' -av ./public/assets/ #{role.user}@#{role.hostname}:#{release_path}/public/assets/;"

But it looks like there's probably a cleaner way to specify the port used when deploying?

danielristic avatar Apr 17 '14 19:04 danielristic

If you set your ssh port in config/deploy/production.rb with:

set :ssh_options, {
  port: 42663
}

Then you could do:

execute "rsync -av -e 'ssh -p #{fetch(:ssh_options)[:port]}' ./public/assets/ #{role.user}@#{role.hostname}:#{release_path}/public/assets/;"

Which isn't pretty, but now you're not repeating yourself or statically defining anything in your compile_assets_locally.cap.

This would fail if ssh_options[:port] is undefined.

christiangenco avatar May 05 '14 00:05 christiangenco

@christiangenco that solution works only when you use the :ssh_options configuration, when you put the port into connection string or in server options, it won't work.

I fixed this by using upload! capistrano function. Unfortunately I didn't figure out how to connect my pull request to this issue.

viktomas avatar Jul 03 '14 08:07 viktomas