首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >capistrano版本3升级令人困惑

capistrano版本3升级令人困惑
EN

Stack Overflow用户
提问于 2014-01-15 13:11:40
回答 1查看 2K关注 0票数 1

我一直在努力将capistrano v2升级到v3 5天,我正在尝试从本地机器部署到ec2实例开发环境。我不能再走下去了。我的踪迹在这里

$cap开发部署:检查

代码语言:javascript
复制
INFO [429e612c] Running /usr/bin/env mkdir -p /tmp/my_app_name/ on 70.22.320.14
DEBUG [429e612c] Command: ( RVM_BIN_PATH=~/.rvm/bin /usr/bin/env mkdir -p /tmp/my_app_name/ )
 INFO [429e612c] Finished in 6.208 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/my_app_name/git-ssh.sh 0.0%
 INFO Uploading /tmp/my_app_name/git-ssh.sh 100.0%
 INFO [c3a41f2e] Running /usr/bin/env chmod +x /tmp/my_app_name/git-ssh.sh on 70.22.320.14
DEBUG [c3a41f2e] Command: ( RVM_BIN_PATH=~/.rvm/bin /usr/bin/env chmod +x /tmp/my_app_name/git-ssh.sh )
 INFO [c3a41f2e] Finished in 0.720 seconds with exit status 0 (successful).
DEBUG [c5891dcc] Running /usr/bin/env git ls-remote git@github.com:example/webapp.git
 on 70.22.320.14
DEBUG [c5891dcc] Command: ( RVM_BIN_PATH=~/.rvm/bin GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app_name/git-ssh.sh /usr/bin/env git ls-remote  git@github.com:example/webapp.git
DEBUG [c5891dcc]    /usr/bin/env: 
DEBUG [c5891dcc]    git
DEBUG [c5891dcc]    : No such file or directory
DEBUG [c5891dcc]    
DEBUG [c5891dcc] Finished in 0.664 seconds with exit status 127 (failed).

config/deploy.rb

代码语言:javascript
复制
set :application, 'my_app_name'
set :repo_url, '.'
set :branch, 'master'
set :scm, :git
set :deploy_to, "/home/ec2-user/capistrano-3/}"
set :ssh_options, {:keys => ["#{ENV['HOME']}/.ssh/my_pem.pem"], :forward_agent =>true}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, '2.0.0-p353'
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
set :whenever_command, "bundle exec whenever"
set :git_shallow_clone, 1
set :deploy_via, :copy

set :log_level, :debug
set :pty, true
set :linked_files, %w{config/database.yml}


SSHKit.config.command_map[:rake]  = "bundle exec rake"
SSHKit.config.command_map[:rails] = "bundle exec rails"

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

  after :finishing, 'deploy:cleanup'

end

config/deploy/development.rb

代码语言:javascript
复制
set :stage, :development


role :app, %w{ec2-user@70.22.320.14}
role :web, %w{ec2-user@70.22.320.14}
role :db,  %w{ec2-user@70.22.320.14}
role :all,  %w{ec2-user@70.22.320.14}

server 'ec2-user@70.22.320.14', user: 'ec2-user', roles: %w{web app}

Capfile

代码语言:javascript
复制
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

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

我的问题:

  1. 我的git路径不被接受
  2. ssh关键问题

git和ssh键与capistrano 2一起工作,与我部署的应用程序相同。升级到capistrano v3会带来更大的头痛。我能连续做些什么。请引导我通过正确的步骤。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-15 14:19:47

我花了一些时间与capistrano3做斗争,下面是一些提示,它们可能是有用的:

1)官方手册capistranorb.com。有一些关于你应该连续做什么的建议。关于认证和授权的章节也很有帮助。有一些关于在工作站和服务器上配置ssh的提示。我遵循了这个指南,它对我有帮助。通过从头开始遵循本指南来构建您的deploy.rb。

还有有用的指南:guide1guide2

2)这是我的Capfile。请注意rvm1 1/capstrano3和capstrano3/unicorn。非常有用的宝石。

代码语言:javascript
复制
    require 'capistrano/setup'

    require 'capistrano/deploy'
    require 'capistrano3/unicorn'
    require 'rvm1/capistrano3'
    require 'capistrano/rvm'
    require 'capistrano/bundler'
    require 'capistrano/rails/assets'
    require 'capistrano/rails/migrations'

3)您可以尝试以下命令:

代码语言:javascript
复制
ssh ubuntu@ec2....amazonaws.com -v 

代码语言:javascript
复制
ssh git@github.com -v   # from your EC2 server

若要了解在尝试连接到EC2服务器时发生了什么,请执行以下操作。可能是佩姆钥匙的问题?创建.pub键并尝试使用它。不要忘记将它添加到~/ssh/authorized_keys中

代码语言:javascript
复制
cat id_rsa_aws.pub | ssh ubuntu@....amazonaws.com "cat >>   
/home/ubuntu/.ssh/authorized_keys"

配置ssh-代理,不要忘记添加~/..bash_profile,如下所示:

代码语言:javascript
复制
eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa_deploy_github
ssh-add ~/.ssh/id_rsa_digital_ocean

如果你对ssh有问题,也许你应该看看这个ssh-指南

你也可以看我的应用程序,在那里我正在使用capistrano3。也许你能为你找到一些东西:#项目

附注:在某些VPS git上没有安装,所以最好检查:

代码语言:javascript
复制
deployer@ec2***.amazonaws.com$ which git

如未找到:

代码语言:javascript
复制
deployer@ec2***.amazonaws.com$ sudo apt-get install git
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21138345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档