Rails-使用Capistrano部署后需要重新启动Nginx吗? [英] Rails - Nginx needs to be restarted after deploying with Capistrano?
问题描述
我正在使用Capistrano部署我的Rails应用程序.每当我部署时,所做的更改都不会反映在浏览器上,并且我仍然需要重新启动nginx来更新站点(运行sudo/etc/init.d/nginx重新启动).我不确定为什么,但是重新启动应用程序后是否应该更新它? (使用触摸/app/tmp/restart.txt)
I am using Capistrano to deploy my Rails application. whenever I deploy, changes would not be reflected on the browser, and I still need to restart nginx to update the site (running sudo /etc/init.d/nginx restart). I'm not really sure why but isn't it supposed to be updated after restarting application? (using touch /app/tmp/restart.txt)
这是我的deploy.rb
Here's my deploy.rb
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.3-p194@app_name'
set :rvm_type, :user
require "bundler/capistrano"
set :application, "app_name"
set :user, "me"
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :copy
set :use_sudo, false
set :scm, :git
set :repository, "~/Sites/#{application}/.git"
set :branch, "master"
role :web, '1.2.3.4'
role :app, '1.2.3.4'
role :db, '1.2.3.4', :primary => true
role :db, '1.2.3.4'
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
推荐答案
I realized that the deployment setup matches http://coding.smashingmagazine.com/2011/06/28/setup-a-ubuntu-vps-for-hosting-ruby-on-rails-applications-2/
当我遵循本教程时(大约一年前),我安装了较新的nginx和passenger版本.从我的记忆中,我认为这些较新的版本促使我在运行任何类型的init.d命令时将nginx用作服务. (Ubuntu 10.04)
When I followed this tutorial(about a year ago), I installed slightly newer versions of nginx and passenger. From what I remember, I think these newer versions prompted me to use nginx as a service when I ran any type of init.d command. (Ubuntu 10.04)
无论如何,我都会切换代码
Anyways I would switch out the code
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
到
run "#{sudo} service nginx #{command}"
看看是否可行.
这篇关于Rails-使用Capistrano部署后需要重新启动Nginx吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!