【发布时间】:2014-10-29 15:13:36
【问题描述】:
我正在尝试使用 Capistrano 部署 Rails 应用程序。我遵循了教程How to Deploy a Rails 4 App with Git and Capistrano。但是,当我运行cap production deploy:check 时,它给了我这个错误:
INFO[349a4b8d] Running /usr/bin/env mkdir -p /tmp/app_name/ on xxx.xx.xxx.xxx
DEBUG[349a4b8d] Command: /usr/bin/env mkdir -p /tmp/app_name/
INFO[cd49f0ac] Running /usr/bin/env mkdir -p /tmp/app_name/ on example.com
DEBUG[cd49f0ac] Command: /usr/bin/env mkdir -p /tmp/app_name/
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xx.xxx.xxx: Authentication failed for user @xxx.xx.xxx.xxx
我的第一个想法是我确实需要使用 sudo,但 mkdir 在 /tmp/ 中不应该需要 sudo。我的第二个想法是它需要 ssh 的密码,但我使用公钥在我的开发计算机和服务器之间进行 ssh。有什么想法吗?
这是我的config/deploy.rb:
lock '3.2.1'
set :application, 'app_name'
set :repo_url, 'git@example.com:remote/app_name.git'
set :scm, :git
set :user, 'deploy'
set :use_sudo, false
set :stage, :production
set :rails_env, 'production'
set :deploy_via, :remote_cache
set :keep_releases, 5
set :ssh_options, { forward_agent: true }
set :pty, true
server 'xxx.xx.xxx.xxx', roles: [:app, :web, :db], primary: true
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 :publishing, :restart
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
end
我正在使用 Ruby 2.1.0、Rails 4.1.4 和 Capistrano 3.2.1。
【问题讨论】:
标签: ruby-on-rails ssh capistrano capistrano3