我在我的Gemfile上使用了capistrano 3.2.1和以下gems:
gem 'capistrano'
gem 'capistrano-safe-deploy-to', '~> 1.1.1'
gem 'capistrano-rvm'
gem 'capistrano-unicorn-nginx', '~> 3.1.0'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-bundler', '~> 1.1.2'
在Capfile上,我有以下内容:
require 'capistrano/setup'
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
#
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/unicorn_nginx'
require 'capistrano/safe_deploy_to'
# require 'capistrano/secrets_yml'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
在deploy.rb上,我有以下内容:
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'MyAoo'
# set :repo_url, 'MyRepoURL'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
# set :branch, 'master'
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, 'project'
# No need to clone entire repo each time
# set :deploy_via, :remote_cache
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :info
# Default value for :pty is false
set :pty, true
# TODO check this
# set :forward_agent, true
# Sudo permissions not required
set :use_sudo, false
# Default value for :linked_files is []
# set :linked_files, %w{ config/database.yml }
# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 3
# set :rvm_type, :user # Defaults to: :auto
# set :rvm_custom_path, '~/.myveryownrvm' # only needed if not detected
# Set ruby version on the server.
set :rvm_ruby_version, '2.1.2' # Defaults to: 'default'
set :rvm_roles, [:app, :web]
现在当我运行$ cap production safe_deploy_to时:确保在我当地我得到以下情况:
$ cap production safe_deploy_to:ensure
DEBUG[7b638604] Running /usr/bin/env [ -d ~/.rvm ] on ABC.DEF.GHI.JK
DEBUG[7b638604] Command: [ -d ~/.rvm ]
DEBUG[7b638604] Finished in 0.738 seconds with exit status 1 (failed).
DEBUG[45e6ecbb] Running /usr/bin/env [ -d /usr/local/rvm ] on 104.131.110.30
DEBUG[45e6ecbb] Command: [ -d /usr/local/rvm ]
DEBUG[45e6ecbb] Finished in 0.042 seconds with exit status 0 (successful).
DEBUG[d7085818] Running /usr/local/rvm/bin/rvm version on 104.131.110.30
DEBUG[d7085818] Command: /usr/local/rvm/bin/rvm version
DEBUG[d7085818] rvm 1.25.33 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[d7085818]
DEBUG[d7085818] Finished in 0.264 seconds with exit status 0 (successful).
rvm 1.25.33 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[7d96ffdc] Running /usr/local/rvm/bin/rvm current on 104.131.110.30
DEBUG[7d96ffdc] Command: /usr/local/rvm/bin/rvm current
DEBUG[7d96ffdc] ruby-2.1.2
DEBUG[7d96ffdc]
DEBUG[7d96ffdc] Finished in 0.257 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG[caa8eec2] Running /usr/local/rvm/bin/rvm 2.1.2 do ruby --version on 104.131.110.30
DEBUG[caa8eec2] Command: /usr/local/rvm/bin/rvm 2.1.2 do ruby --version
DEBUG[caa8eec2] ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
DEBUG[caa8eec2]
DEBUG[caa8eec2] Finished in 0.454 seconds with exit status 0 (successful).
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
INFO[68eea9b0] Running /usr/bin/env sudo mkdir -pv /var/www/myapp on 104.131.110.30
DEBUG[68eea9b0] Command: /usr/bin/env sudo mkdir -pv /var/www/myapp
DEBUG[68eea9b0] [sudo] password for marvin:
它仍然卡在那里,没有办法输入密码或提示中的任何内容。我无法理解为什么在我向部署者提供sudo权限时要求输入密码?
我错过了什么?
答案 0 :(得分:2)
我是capistrano-safe-deploy-to
插件的创建者。由于任务卡在此命令/usr/bin/env sudo mkdir -pv /var/www/myapp
上,因此插件似乎存在问题。
我建议您使用deploy.rb
中的删除(或已注释掉)选项重新运行capistrano命令:
使用上述2个选项的默认值可以正常工作,无需覆盖它们。
如果您仍有问题,请打开capistrano-safe-deploy-to
插件的问题,我会尽力提供帮助。