即使乘客正在运行,Rails页面也不显示

时间:2012-09-18 09:25:03

标签: ruby-on-rails-3 nginx capistrano passenger web-deployment

我正在尝试部署我的第一个正确的Rails项目。 我有一个安装了Nginx,Passenger和PostgreSQL的Ubuntu 12.04虚拟服务器。 我已使用Capistrano将代码部署到服务器。

一切都应该有效,但出于某种原因,当试图通过浏览器访问页面时,它只是尝试连接大约10秒然后超时。 但是,所有静态页面(例如address / 500.html和address / robots.txt)都会正确加载。

我已经检查了/ opt / nginx / logs中的Nginx错误日志,但它们都是空的。另一方面,Nginx访问日志仅记录我的一些尝试。 Nginx访问日志:

130.233.194.3 - - [18/Sep/2012:11:13:04 +0300] "GET /somestuff HTTP/1.1" 301 5 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
130.233.194.3 - - [18/Sep/2012:11:37:59 +0300] "GET /500.html HTTP/1.1" 200 643
"-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
130.233.194.3 - - [18/Sep/2012:11:45:59 +0300] "-" 400 0 "-" "-"
130.233.194.3 - - [18/Sep/2012:11:57:32 +0300] "GET /500.html HTTP/1.1" 200 643
"-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
130.233.194.3 - - [18/Sep/2012:11:57:47 +0300] "GET /favicon.ico HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
130.233.194.3 - - [18/Sep/2012:11:58:19 +0300] "GET /robots.txt HTTP/1.1" 200 204 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"

(例如,在/ somestuff之后,我尝试/ nopage,但它没有记录)

My Rails App生产日志仅显示数据库迁移。我也可以在生产模式下打开Rails控制台并将内容写入数据库,所以我认为这不是问题所在。

如果我在rails控制台中写“app.get(”/“)”或任何其他页面,它将只返回301 (不知道这是否相关,在我的发展环境中它返回200)

以下是一些可能相关的其他文件:

nginx.conf:

#user  [User used in deploying];
   server {
        listen 80;
        server_name [Name_of_the_server];
        root /home/[User used in deploying]/srv/nsbg/current/public;
        passenger_enabled on;
}

(这就是我添加的内容,否则是默认值)

Capistrano部署文件:

require 'bundler/capistrano'
set :user, '[User used in deploying]'
set :domain, '[server name]'
set :applicationdir, "/home/[User used in deploying]/srv/nsbg"

set :scm, 'git'
set :repository,  "[Github repo]"
set :git_enable_submodules, 1 # if you have vendored rails
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true

# roles (servers)
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export

# additional settings
default_run_options[:pty] = true  # Forgo errors when deploying from windows
#ssh_options[:keys] = %w(/home/user/.ssh/id_rsa)            # If you are using ssh_keysset :chmod755, "app config db lib public vendor script script/* public/disp*"set :use_sudo, false

# Passenger
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

使用命令“sudo passenger-status”:

----------- General information -----------
max      = 6
count    = 1
active   = 0
inactive = 1
Waiting on global queue: 0

----------- Application groups -----------
/home/[User used in deploying]/srv/nsbg/current:
  App root: /home/[User used in deploying]/srv/nsbg/current
  * PID: 8038    Sessions: 0    Processed: 1       Uptime: 1h 4m 29s

就像我说的那样,静态页面会被提供,但任何其他页面(包括无效路由)都会挂断,并且不会在任何地方写入错误。 请帮助我,我在部署和完全失去方面非常缺乏经验

0 个答案:

没有答案