Reputation: 531
I am in the proces of migrating from Passenger to Unicorn and I am having a bit of trouble getting the configuration working.
The issue that I am seeing is that all of my connections seem to time out, but there are no errors logged in the stderr.log and stdout.log files. I have verified that my ports are open on the AWS sec group.
This is what I am seeing in my stderr.log
I, [2012-08-21T19:26:36.462776 #7989] INFO -- : unlinking existing socket=/data/test/staging/current/tmp/sockets/unicorn.sock
I, [2012-08-21T19:26:36.463048 #7989] INFO -- : listening on addr=/data/test/staging/current/tmp/sockets/unicorn.sock fd=3
I, [2012-08-21T19:26:36.463466 #7989] INFO -- : Refreshing Gem list
I, [2012-08-21T19:27:50.293399 #7989] INFO -- : master process ready
I, [2012-08-21T19:27:50.687491 #8083] INFO -- : worker=0 ready
I, [2012-08-21T19:27:50.751790 #8086] INFO -- : worker=1 ready
cache: [GET /] miss
Here is my current configuration structure:
nginx.conf
user www-data;
worker_processes 2;
daemon off;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
server_names_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
unicorn.rb
worker_processes 2
working_directory "/data/test/staging/current"
preload_app true
timeout 30
listen "/data/test/staging/current/tmp/sockets/unicorn.sock", :backlog => 64
pid "/data/test/staging/current/tmp/pids/unicorn.pid"
# Set the path of the log files inside the log folder of the testapp
stderr_path "/data/test/staging/current/log/unicorn.stderr.log"
stdout_path "/data/test/staging/current/log/unicorn.stdout.log"
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
000-default
upstream test_server {
#This is the socket we configured in unicorn.rb
server unix:/data/test/staging/current/tmp/sockets/unicorn.sock »
fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name http://ec2-23-22-53-139.compute-1.amazonaws.com;
keepalive_timeout 5;
# Location of our static files
root /data/test/staging/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://test_server;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /data/test/staging/current/public;
}
}
Upvotes: 1
Views: 3567
Reputation: 1495
I would start by putting the Socket and Pid files in the shared directory. EG,
/data/test/staging/shared/sockets
/data/test/staging/shared/pids
This will help when the application is deployed and the "current folder" changed to the next release (assuming you are deployin with capistrano).
Upvotes: 1