我正在使用 capistrano 在此 Railscasts 中由 Ryan Bates 描述的其他服务中安装 nginx。下面的 nginx.rb 文件是从他的源代码中复制而来的。安装过程到线时
* executing "sudo -p 'sudo password: ' add-apt-repository ppa:nginx/stable"
它会发出警告并要求我通过按 ENTER 或控制 c 来确认以继续。但是,由于这不是手动安装,我无法按 Enter 键继续。安装脚本被冻结,等待我无法手动输入的命令。有没有办法修改下面的 nginx.rb 文件来处理这种情况呢?
triggering after callbacks for `deploy:install'
* 2013-07-11 10:17:36 executing `nginx:install'
* executing "sudo -p 'sudo password: ' add-apt-repository ppa:nginx/stable"
servers: ["192.XXX.XXX.XXX"]
[192.XXX.XXX.XXX] executing command
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] You are about to add the following PPA to your system:
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] Stable version of nginx.
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] The following are no longer updated past 1.2.7, due to PPA build restrictions:
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] * Maverick
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] The following will not be updated past 1.4.1, except for bugfixes which may have been missed:
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] * Lucid
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] * Natty
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] * Oneiric
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] More info: https://launchpad.net/~nginx/+archive/stable
** [out :: 192.XXX.XXX.XXX]
** [out :: 192.XXX.XXX.XXX] Press [ENTER] to continue or ctrl-c to cancel adding it
** [out :: 192.XXX.XXX.XXX]
nginx.rb
namespace :nginx do
desc "Install latest stable release of nginx"
task :install, roles: :web do
run "#{sudo} add-apt-repository ppa:nginx/stable"
run "#{sudo} apt-get -y update"
run "#{sudo} apt-get -y install nginx"
end
after "deploy:install", "nginx:install"
desc "Setup nginx configuration for this application"
task :setup, roles: :web do
template "nginx_unicorn.erb", "/tmp/nginx_conf"
run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}"
run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
restart
end
after "deploy:setup", "nginx:setup"
%w[start stop restart].each do |command|
desc "#{command} nginx"
task command, roles: :web do
run "#{sudo} service nginx #{command}"
end
end
end