capistrano deploy from one local directory to another
Solution 1
The localhost
issue is because you're setting this in the role
definitions. Since you're doing all this locally, and since Capistrano requires a role, you can set the following:
role :app, ""
I also think you're setting the copy_dir
and copy_remote_dir
values incorrectly. I'd recommend removing these and letting Capistrano use it's defaults.
Here's a full config which should work for you:
role :app, ""
set :use_sudo, false
set :application, 'thesis' # you'll need to specify an app name
set :repository, "."
set :scm, :none
set :deploy_to, "/home/thesis/deploy/" # the destination dir
set :deploy_via, :copy
# override deploy:restart since this isn't a Rails app
namespace :deploy do
task :restart do
# no-op
end
end
Solution 2
Maybe you're missing a SSH server to connect on your on machine because you only have the client installed.
Test ssh 127.0.0.1
, if you still get a connection refuse error, use:
sudo apt-get install openssh-server
To install the ssh server.
Solution 3
I also get this problem, for I had set SSH port to 13000, not the default port 22. And the /etc/hosts.deny added
sshd:ALL
/etc/hosts.allow added
sshd:#some allowed IPs
I processing are:
1) add to deploy.rb
ssh_options[:port] = 13600
2) add localhost to hosts.allow
sshed:127.0.0.1 localhost # others allowed IPs
Solution 4
You need to have an ssh server installed for local deployment to work, such as openssh (sudo apt-get install openssh-server
to install)
config/deploy/staging.rb
set :stage, :staging
role :app, %w{127.0.0.1}
role :web, %w{127.0.0.1}
role :db, %w{127.0.0.1}
server '127.0.0.1', user: 'your-username', roles: %w{web app}
set :branch, "staging"
config/deploy.rb
set :deploy_to ,'/home/your/app/path/deploy'
# Path of tests to be run, use array with empty string to run all tests
set :tests, ['']
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :run_tests do
test_log = "log/capistrano.test.log"
tests = fetch(:tests)
tests.each do |test|
puts "--> Running tests: '#{test}', please wait ..."
unless system "bundle exec rspec #{test} > #{test_log} 2>&1"
puts "--> Aborting deployment! One or more tests in '#{test}' failed. Results in: #{test_log}"
exit;
end
puts "--> '#{test}' passed"
end
puts "--> All tests passed, continuing deployment"
system "rm #{test_log}"
end
# Only allow a deploy with passing tests to be deployed
before :deploy, "deploy:run_tests"
end
Run it with with
cap staging deploy
thesis
Updated on July 10, 2022Comments
-
thesis almost 2 years
I want to deploy application on my local machine. For example I have my Rails APP in:
/home/thesis/dev/myapp
but I want tocap deploy:setup
to/home/thesis/deploy/
. I have tried that but capistrano tries to connect tolocalhost
, but it is not needed at all. How can I solve it?Here goes my deploy.rb
role :app, "localhost" role :web, "localhost" role :db, "localhost", :primary => true set(:deploy_to) { "/home/thesis/dev/myapp" } set :bundle_without, [:development, :test] set :use_sudo, false set :repository, "." set :scm, :none set :deploy_via, :copy set :copy_dir, "/home/thesis/deploy/tmp" set :copy_remote_dir, "/home/thesis/deploy/tmp"
It drops with:
connection failed for: localhost (Errno::ECONNREFUSED: Connection refused - connect(2))