我在部署時使用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文件。它有一些如上所述的密碼問題。我如何克服所有問題才能正確部署。
預先感謝任何幫助
我有同樣的問題,你有沒有設法找到一個解決問題 – Martinffx
@Martinffx? - 其實這不是一個問題,它的工作原理正確地看到下面的回答這個問題,我發表在我的deplo的初始時間。英。閱讀http://capistranorb.com/2013/06/01/release-announcement.html這個。你可以理解很多。 – Sam