1

I want to deploy my project with capistrano. Here is my settings file:

deploy.rb

require "capistrano/ext/multistage"
require "capistrano_colors"
require "bundler/capistrano"

require "rvm/capistrano"                       # Load RVM"s capistrano plugin.

set :application, "project"
set :copy_exclude, %w(.git .gitignore doc features log spec test tmp Capfile)
#set :shared_children, shared_children + %w(public/uploads)

set :use_sudo, false
set :user, "app"

set :stages, %w(staging production)

namespace :deploy do
  task :start, roles: :app, except: { no_release: true } do
    run "cd #{current_path} && bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D"
  end

  task :stop, roles: :app, except: { no_release: true } do
    run "kill -KILL -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
  end

  task :restart, roles: :app, except: { no_release: true } do
    stop
    start
  end
end

def confirm
  puts "\n\e[0;36m#{stage}\e[0m\e[0;31m Do you really deploy? (yes/no) \e[0m\n"
  proceed = STDIN.gets rescue nil
  exit unless proceed.chomp! == "yes"
end

For the multistage, I have created two files (one by environment): deploy/production.rb

server "myserver.net", :app, :web, :db, primary: true
set :rails_env, "production"

set :rvm_type, :user
set :rvm_ruby_string, "ruby-2.0.0-p0"

set :scm, :git
set :repository, 'ssh://[email protected]:54333/~/git-workspace/myproject.git'
set :deploy_via, :remote_cache

confirm

and almost the same for the staging one.

( As you have guessed, I have changed project, server name and port number for security purposes)

I first executed :

bundle exe cap production deploy:check

then :

bundle exe cap production deploy:setup

without any problem, when calling the deploy command (bundle exe cap production deploy), i get the below message :

xxxx-no-MacBook-Air:myproject xxxx$ bundle exe cap deploy
    triggering load callbacks
    triggering start callbacks for `deploy'
  * 2013-10-08 13:43:12 13:43:12 == Currently executing `multistage:ensure'
No stage specified. Please specify one of: staging, production (e.g. `cap staging deploy')
xxxx-no-MacBook-Air: xxxx$ bundle exe cap production deploy
    triggering load callbacks
  * 2013-10-08 13:43:18 13:43:18 == Currently executing `production'

production Do you really want to deploy? (yes/no) 
yes
    triggering start callbacks for `deploy'
  * 2013-10-08 13:43:20 13:43:20 == Currently executing `multistage:ensure'
  * 2013-10-08 13:43:20 13:43:20 == Currently executing `deploy'
  * 2013-10-08 13:43:20 13:43:20 == Currently executing `deploy:update'
 ** transaction: start
  * 2013-10-08 13:43:20 13:43:20 == Currently executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote ssh://[email protected]:54333/~/git-workspace/myproject.git HEAD"
 Bonjour xxxx                                
[email protected]'s password: 
    command finished in 6010ms
  * executing "if [ -d /u/apps/myproject/shared/cached-copy ]; then cd /u/apps/myproject/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e000681dc88244f04ac2e82dd2cf8d94bfa9d930 && git clean -q -d -x -f; else git clone -q ssh://[email protected]:54333/~/git-workspace/myproject.git /u/apps/myproject/shared/cached-copy && cd /u/apps/myproject/shared/cached-copy && git checkout -q -b deploy e000681dc88244f04ac2e82dd2cf8d94bfa9d930; fi"
    servers: ["myserver.net"]
Enter passphrase for /Users/myname/.ssh/id_rsa: 
    [myserver.net] executing command
 ** [myserver.net :: out]  Bonjour xxxx
 ** [myserver.net :: out] [email protected]'s password:
Password: 
 ** [myserver.net :: out]
 ** [myserver.net :: out] Permission denied, please try again.
 ** [email protected]'s password:
Password: 
 ** [myserver.net :: out]
 ** [myserver.net :: out] Permission denied, please try again.
 ** [email protected]'s password:
Password: 
 ** [myserver.net :: out]
 ** [myserver.net :: out] Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
 ** [myserver.net :: out] fatal: The remote end hung up unexpectedly
    command finished in 36598ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /u/apps/myproject/releases/20131008044412; true"
    servers: ["myserver.net"]
    [myserver.net] executing command
    command finished in 1182ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'ruby-2.0.0-p0' -c 'if [ -d /u/apps/myserver/shared/cached-copy ]; then cd /u/apps/myserver/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e000681dc88244f04ac2e82dd2cf8d94bfa9d930 && git clean -q -d -x -f; else git clone -q ssh://[email protected]:54333/~/git-workspace/myproject.git /u/apps/myproject/shared/cached-copy && cd /u/apps/myproject/shared/cached-copy && git checkout -q -b deploy e000681dc88244f04ac2e82dd2cf8d94bfa9d930; fi'" on myserver.net

xxx-no-MacBook-Air:myprojectxxxxx$ 

I have generated keys (in my local environment) and put the public one in the authorized_keys file (server side).

1 Answer 1

1

You seem to have taken a lot of the right steps, so now with this kind of error, you should test the permissions directly:

  1. Ensure that you can ssh from your development machine (where you're running capistrano) to the deployment server as that user. (E.g., that might be something along the lines of ssh [email protected].
  2. Once you've made sure that works, then while logged in on the server, as the deployment user, try connecting to the repository server. E.g., something like ssh -T [email protected] as described here.

99% of the time, if you can do these two things successfully, there will be no permissions problems.

1
  • Connection between the repository server and the production server was the issue ! (btw, I am not using github) . Thank you, it works now.
    – johann
    Commented Oct 10, 2013 at 5:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.