rdudacz
By:
rdudacz

Deployment a Rails 3 app with using Capistrano 3

July 27, 2014 6.1k views

Hello guys,

I am trying to deploy a Rails app to Ubuntu server (nginx, unicorn) with using Capistrano 3.

Here's the setup:

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

deploy.rb

lock '3.2.1'

set :application, 'myappname'
set :scm, :git
set :repo_url, 'git@bitbucket.org:username/repo.git'
set :branch, "master"

set :format, :pretty
set :pty, true

set :log_level, :info

set :linked_files, %w{config/database.yml config/config.yml}
set :linked_dirs, %w{bin log tmp vendor/bundle public/system}

set :keep_releases, 5

production.rb;

set :stage, :production
set :branch, "master"

role :app, %w{deployer@IP}
role :web, %w{deployer@IP}
role :db,  %w{deployer@IP}

server "IP", user: "deployer", roles: %w{web}, primary: true

set :deploy_to, "/home/deployer/apps/myappname"
set :rails_env, :production

set :ssh_options, {
    forward_agent: true,
    auth_methods: %w(password),
    password: 'pass',
    user: 'deployer',
    port: 22
}

set :enable_ssl, false

When I run cap production deploy, I get this error message:

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
rvm 1.25.0 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
ruby-2.0.0-p353
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO[9144fc1d] Running /usr/bin/env mkdir -p /tmp/revi/ on IP
INFO[9144fc1d] Finished in 0.045 seconds with exit status 0 (successful).
INFOUploading /tmp/revi/git-ssh.sh 100.0%
INFO[083993db] Running /usr/bin/env chmod +x /tmp/revi/git-ssh.sh on 188.226.201.73
INFO[083993db] Finished in 0.026 seconds with exit status 0 (successful).
** Execute git:check
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 188.226.201.73: exit
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `exit'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `block (4 levels) in <top (required)>'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:27:in `block (3 levels) in <top (required)>'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SystemExit: exit
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `exit'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in `block (4 levels) in <top (required)>'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:27:in `block (3 levels) in <top (required)>'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/radek/.rvm/gems/ruby-2.0.0-p481/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => git:check
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing on host IP: exit>
** Invoke deploy:failed (first_time)
** Execute deploy:failed

Any tips how to solve this issue? I get successfully SSH to the server, but through Capistrano, I am receiving this error message.

I'd be happy for every tip to help me out with this issue!

Thanks!

1 Answer

Is 'IP' just a placeholder, or is that you actually have in your configs?

server "IP", user: "deployer", roles: %w{web}, primary: true

This should be your actual ip address

Have another answer? Share your knowledge.