2014-01-15 72 views
1

我正在努力將capistrano v2升級到v3 5天。我試圖從本地機器部署到ec2實例開發環境。我無法繼續前進。我的痕跡在這裏capistrano版本3升級困惑

$帽開發部署:檢查

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 [email protected]: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 [email protected]: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). 

配置/ deploy.rb

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 

配置/部署/ development.rb

set :stage, :development 


role :app, %w{[email protected]} 
role :web, %w{[email protected]} 
role :db, %w{[email protected]} 
role :all, %w{[email protected]} 

server 'ec2-user[email protected]', user: 'ec2-user', roles: %w{web app} 

Capfile

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會帶來更大的頭疼。我可以連續做什麼。請指導我正確的步驟

+1

無需''SSHKit.config.command_map':rake'和': rails','capistrano/bundler'負責。 –

+1

另外,只需要'server'和'role:app /:web /:db'中的一個。在這種情況下,我認爲'服務器'覆蓋特定的':app /:web /:db' –

回答

4

我花了一些時間與capistrano3掙扎,這裏有一些提示,可能是他們可能是有用的:

1)官方手冊capistranorb.com。有關於你應該連續做什麼的提示。關於認證和授權的部分也很有幫助。有關於在工作站和服務器上配置ssh的一些提示。我遵循這個指南,它可以幫助我。嘗試從頭開始遵循本指南來構建您的deploy.rb。

也很有幫助指南:guide1guide2

2)這是我的Capfile。注意rvm1/capistrano3和capistrano3 /獨角獸。非常有用的寶石。

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)你可以試試下面的命令:

ssh [email protected] -v 

ssh [email protected] -v # from your EC2 server 

瞭解,當您試圖連接到您的EC2服務器會發生什麼。可能與pem key有關的問題?創建.pub項並嘗試使用它。不要忘了將它添加到〜/ SSH/authorized_keys中

cat id_rsa_aws.pub | ssh [email protected] "cat >> 
/home/ubuntu/.ssh/authorized_keys" 

配置您的ssh-agent和別忘了在你的〜/添加。.bash_profile中是這樣的:

eval $(ssh-agent) 
ssh-add ~/.ssh/id_rsa_deploy_github 
ssh-add ~/.ssh/id_rsa_digital_ocean 

如果您在使用SSH的問題,或許你應該看看這個ssh-guide

還可以看我的應用程序,在那裏我使用capistrano3。可能你可以找到適合你的東西:#project

P.在沒有安裝一些VPS git的,所以它是最好檢查:

[email protected]***.amazonaws.com$ which git 

如果沒有找到:

[email protected]***.amazonaws.com$ sudo apt-get install git 
+1

我的遠程服務器不包含git。所以我在我的遙控器中添加了git。現在我的問題解決了 – Sam

+0

謝謝接受你的答案 – Sam