我正在使用capistrano安装nginx以及其他服务,如Ryan Bates在此Railscasts中所述。下面的nginx.rb文件是从他的源代码中复制的。当安装过程到达线如何按'输入以继续'与capistrano的自动安装
* 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
谢谢,我会尝试了这一点,并接受你的答案,如果它的工作原理 – Leahcim
@biomancer任何想法如何与使用该capistrano 3? – Mohamad
@Mohamad我对capistrano 3没有经验,对不起。 – biomancer