2014-01-07 117 views
4

我在部署時使用capistrano 3時出現問題。即使我提到部署路徑(deploy_to),我的應用程序默認運行到/ tmp目錄中。運行git-ssh腳本時,會出現一些權限被拒絕的錯誤。部署時使用capistrano 3時出現問題

$ 帽開發部署:檢查

INFO [8ad6d60d] Running mkdir -p /tmp/myapp/ on 40.12.255.11 
INFO [8ad6d60d] Finished in 10.468 seconds with exit status 0 (successful). 
INFO Uploading /tmp/myapp/git-ssh.sh 100.0% 
INFO [b1e9863e] Running chmod +x /tmp/myapp/git-ssh.sh on 40.12.255.11 
INFO [b1e9863e] Finished in 8.093 seconds with exit status 0 (successful). 

$ 貓/tmp/myapp/git-ssh.sh

#!/bin/sh -e 

exec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no "[email protected]" 

配置/ deploy.rb

set :application, "myapp" 
set :scm, :git 
set :repo_url, "[email protected]:example/webapp.git" 
set :deploy_to, "/home/ec2-user/capistrano-3/myapp" 
set :ssh_options, {:keys => ["#{ENV['HOME']}/.ssh/myapp.pem"] } 

set :log_level, :info 
set :rvm_ruby_string, '2.0.0' 
set :rvm_type, :user 

set :branch, "master" 
set :user, "ec2-user" 
set :use_sudo, false 
set :keep_releases, 2 
set :git_shallow_clone, 1 
set :deploy_via, :copy 

set :whenever_command, "bundle exec whenever" 
require 'sidekiq/capistrano' 

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 

Capfile

require 'capistrano/setup' 
require 'capistrano/deploy' 
require 'capistrano/rvm' 
require 'capistrano/bundler' 

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

配置/部署/ development.rb

set :deploy_to, "/home/ec2-user/capistrano-3/myapp" 
set :rails_env, "development" 
set :unicorn_env, "development" 
server "[email protected]", user: "ec2-user", roles: %w{web app db} 
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master" 

我的問題是

1.爲什麼TMP/MyApp的產生?我已經提到了deploy_to中的路徑。如何克服這一點?

2.如何避免生成git-ssh.sh文件。它有一些如上所述的密碼問題。我如何克服所有問題才能正確部署。

預先感謝任何幫助

+0

我有同樣的問題,你有沒有設法找到一個解決問題 – Martinffx

+0

@Martinffx? - 其實這不是一個問題,它的工作原理正確地看到下面的回答這個問題,我發表在我的deplo的初始時間。英。閱讀http://capistranorb.com/2013/06/01/release-announcement.html這個。你可以理解很多。 – Sam

回答

1
  1. /tmp/myapp實際上並不是應用程序正在運行的位置。它是git:wrapper任務的一部分,它創建該文件夾並檢查它是否具有正確的權限。一旦你部署它將輸出到你指定的正確文件夾「/ home/ec2-user/capistrano-3/myapp」

  2. 請附上錯誤日誌以便更好地瞭解發生了什麼。部署:檢查在「退出狀態0(成功)」之上成功。「

您可以更改使用:tmp_dir 參考tmp目錄:https://github.com/capistrano/capistrano/blob/master/README.md#configuration

-1

此命令可以解決問題capistrano3

cap jefferson deploy:setup

cap jefferson deploy:check

cap jefferson deploy

重啓系統

+0

你有V.M.S嗎? – Sam

+0

不要再做一次 – Sam

0

來解決這個問題下面的行需要在deploy.rb文件添加:

set :tmp_dir, "/home/user/tmp"