Capistrano deploy:cold doesn't work

2019-06-12 10:11发布

问题:

I have two Questions. One small and one greater problem.

  1. Why i have to enter the passphrase 10 times my running cap:cold
  2. After i tryed to setup an capistrano via teachmetocode-tuorial and with some helps of stackoverflow. I sat down, with many tutorials of deploying capistrano and write my own new Version of the deploy.rb Our gem env output looks so

    RubyGems Environment:

    • RUBYGEMS VERSION: 1.8.15
      • RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-linux]
      • INSTALLATION DIRECTORY: /home/user/.rvm/gems/ruby-1.9.3-p125@myapp
      • RUBY EXECUTABLE: /home/user/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
      • EXECUTABLE DIRECTORY: /home/user/.rvm/gems/ruby-1.9.3-p125@myapp/bin
      • RUBYGEMS PLATFORMS:
      • ruby
      • x86_64-linux
      • GEM PATHS:
        • /home/user/.rvm/gems/ruby-1.9.3-p125@myapp
        • /home/user/.rvm/gems/ruby-1.9.3-p125@global
      • GEM CONFIGURATION:
        • :update_sources => true
        • :verbose => true
        • :benchmark => false
        • :backtrace => false
        • :bulk_threshold => 1000
      • REMOTE SOURCES:
        • http://rubygems.org/

And our deploy.rb is here

require "bundler/capistrano"
set :application, "myapp"
set :repository,  "#{application}@myserver:/home/git/repos/#{application}.git"
set :scm, :git
set :user, "#{application}"
set :use_sudo, false
set :deploy_to, "/home/#{application}/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 5

server "myserver", :app, :web, :db, :primary => true

set :branch, "master"

ssh_options[:forward_agent] = false
default_run_options[:pty] = true

before "deploy:assets:precompile", "bundle:install"

load 'deploy/assets'

namespace :deploy do
 task :start do ; end
 task :stop do ; end
 task :restart, :roles => :app, :except => { :no_release => true } do
   run "touch #{File.join(current_path,'tmp','restart.txt')}"
 end
end

Our Developmentsetup We use Apache+Passagner and the rvm installation of http://beginrescueend.com/rvm/install/. On the server we install it on the same way. Every User(apps, gemsets or realuser) have to be a member of group rvm... We use modrails to install the passagner... http://www.modrails.com/documentation/Users%20guide%20Apache.html#_installing_via_the_gem

But why get i an error when i use cap deploy:cold. The cap deploy:check say You appear to have all necessary dependencies installed The error is here

 triggering after callbacks for `deploy:finalize_update'
  * executing `bundle:install'
  * executing "ls -x /home/myapp/myapp/releases"
    servers: ["myserver"]
    [myserver] executing command
    [myserver] sh -c 'ls -x /home/myapp/myapp/releases'
    command finished in 82ms
  * executing "cd /home/myapp/myapp/releases/20120331143114 && bundle install --gemfile /home/myapp/myapp/releases/20120331143114/Gemfile --path /home/m
ahaloo/myapp/shared/bundle --deployment --quiet --without development test"
    servers: ["myserver"]
    [myserver] executing command
    [myserver] sh -c 'cd /home/myapp/myapp/releases/20120331143114 && bundle install --gemfile /home/myapp/myapp/releases/20120331143114/Gemfile --path /h
ome/myapp/myapp/shared/bundle --deployment --quiet --without development test'
 ** [out :: myserver] sh: bundle: not found
    command finished in 73ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/myapp/myapp/releases/20120331143114; true"
    servers: ["myserver"]
    [myserver] executing command
    [myserver] sh -c 'rm -rf /home/myapp/myapp/releases/20120331143114; true'
    command finished in 171ms
failed: "sh -c 'cd /home/myapp/myapp/releases/20120331143114 && bundle install --gemfile /home/myapp/myapp/releases/20120331143114/Gemfile --path /home/
myapp/myapp/shared/bundle --deployment --quiet --without development test'" on myserver
marcus@lenny:~/dev/workspace/myapp$

Our bundle list is here

 * actionmailer (3.2.0)
 * actionpack (3.2.0)
 * activemodel (3.2.0)
 * activerecord (3.2.0)
 * activeresource (3.2.0)
 * activesupport (3.2.0)
 * arel (3.0.2)
 * builder (3.0.0)
 * bundler (1.1.1)
 * capistrano (2.11.2)
 * coffee-rails (3.2.1)
 * coffee-script (2.2.0)
 * coffee-script-source (1.2.0)
 * erubis (2.7.0)
 * execjs (1.3.0)
 * highline (1.6.11)
 * hike (1.2.1)
 * i18n (0.6.0)
 * journey (1.0.3)
 * jquery-rails (1.0.17)
 * json (1.6.5)
 * libv8 (3.3.10.4)
 * mail (2.4.4)
 * mime-types (1.17.2)
 * multi_json (1.1.0)
 * net-scp (1.0.4)
 * net-sftp (2.0.5)
 * net-ssh (2.3.0)
 * net-ssh-gateway (1.1.0)
 * polyglot (0.3.3)
 * rack (1.4.1)
 * rack-cache (1.2)
 * rack-ssl (1.3.2)
 * rack-test (0.6.1)
 * rails (3.2.0)
 * railties (3.2.0)
 * rake (0.9.2.2)
 * rdoc (3.12)
 * sass (3.1.15)
 * sass-rails (3.2.0)
 * simple_form (2.0.1)
 * sprockets (2.1.2)
 * sqlite3 (1.3.5)
 * therubyracer (0.9.10)
 * thor (0.14.6)
 * tilt (1.3.3)
 * treetop (1.4.10)
 * tzinfo (0.3.32)
 * uglifier (1.2.3)
 * uuidtools (2.1.2)

Can someone help us please to get a working capistrano

回答1:

Check your Capistrano path by doing cap shell, then echo $PATH. U'll probably see your standard /usr/local/bin and /usr/bin, but that's not where RVM has Bundler

Edit your Capistrano config/deploy.rb file, and add the following lines:

# Add RVM's lib directory to the load path.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))

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

set :rvm_ruby_string, '1.9.2'
set :rvm_type, :user  # Don't use system-wide RVM

Rails 3 -- Bundler/Capistrano Errors



回答2:

To the problem 1 (type password many times):

You can generate a public/private key pair in your local machine with

ssh-keygen -t rsa (Enter for all)

This will generate two files in /home/LOCAL_USER/.ssh/ directory (id_rsa and id_rsa.pub)

Then in the server create or edit the file /home/user/.ssh/authorized_keys and add the content of the id_rsa.pub

With this, your local machine is authorized to access this server (logging with user) without asking password.



回答3:

You did not used rvm-capistrano integration, the integration is described here:

  • https://rvm.beginrescueend.com/integration/capistrano/

Please note that rvm-capistrano is no longer part of RVM installation, it's separate gem, you need to include it in your Gemfile and require in config/deploy.rb also do not forget to set set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")