Я получаю сообщение об ошибке cache: [GET /] miss
для моего приложения на Rails 3.2.
Я использую nginx в качестве прокси-сервера для сервера единорога и развертываюсь с capistrano.Когда я запускаю сервер, я получаю много повторяющихся ошибок, подобных приведенной выше.Capistrano определенно прекомпилирует ресурсы во время развертывания.Я включаю файлы конфигурации ниже (извините за подробность).
Любые идеи или хотя бы подсказка для выяснения, что не так?
application.rb
config.assets.enabled = true
production.rb
# Disable Rails's static asset server
# (Apache or nginx SHOULD already do this BUT THEY DON'T)
config.serve_static_assets = true
# Don't fallback to assets pipeline if a precompiled asset is missed
# If I disable this I don't get assets served at all
config.assets.compile = true
deploy.rb
require 'bundler/capistrano'
set :application, "network"
set :rails_env, "production"
set :deploy_to, "/var/www/#{application}"
set :repository, "/var/repo/#{application}.git".
set :branch, "master"
set :use_sudo, false
set :user, "root"
set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"
set :bundle_roles, [:app]
set :normalize_asset_timestamps, false
set :scm, :git
server "mydomain.ru", :app, :web, :db, :primary => true
namespace :deploy do
task :restart do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -USR2 `cat #{unicorn_pid}`; else cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi"
end
task :start do
run "cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D"
end
task :stop do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
end
end
unicorn.rb
DEPLOY_TO = "/var/www/network"
RAILS_ROOT = "#{DEPLOY_TO}/current"
PID_FILE = "#{DEPLOY_TO}/shared/pids/unicorn.pid"
SOCKET_FILE = "#{DEPLOY_TO}/shared/unicorn.sock"
LOG_FILE = "#{RAILS_ROOT}/log/unicorn.log"
ERR_LOG = "#{RAILS_ROOT}/log/unicorn_error.log"
OLD_PID = PID_FILE + '.old'
listen SOCKET_FILE, :backlog => 1024
timeout 30
worker_processes 2
user "danchenkov", "danchenkov"
working_directory RAILS_ROOT
pid PID_FILE
stderr_path ERR_LOG
stdout_path LOG_FILE
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_exec do |server|
ENV["BUNDLE_GEMFILE"] = "#{rails_root}/Gemfile"
end
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[:pid]}.old"
if File.exists?(old_pid) && old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
sleep 1
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
nginx.conf
###############################################################################
#
# UNICORN UPSTREAM
#
###############################################################################
upstream unicorn_network_app_server {
server unix:/var/www/network/shared/unicorn.sock fail_timeout=0;
}
###############################################################################
#
# NETWORK - PROXY TO UNICORN ON UNIX SOCKET
#
###############################################################################
server {
listen 80;
server_name network.mydomain.ru;
client_max_body_size 1G;
access_log /var/log/nginx/network.access.log main;
error_log /var/log/nginx/network.error.log notice;
keepalive_timeout 5;
root /var/www/network/current/public;
try_files $uri/index.html $uri.html $uri @network_app;
# Main location
location @network_app {
proxy_pass http://unicorn_network_app_server;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/network/current/public;
}
}