我正在使用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