# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
#worker_processes (rails_env == 'production' ? 16 : 4)
worker_processes 6
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
# Restart any workers that haven't responded in 30 seconds
timeout 30
# Listen on a Unix data socket
listen '/tmp/unicorn.sock', :backlog => 2048
root = "/www"
working_directory root
# Define Log paths
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
##
# REE
# http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
before_fork do |server, worker|
##
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
# immediately start loading up a new version of itself (loaded with a new
# version of our app). When this new Unicorn is completely loaded
# it will begin spawning workers. The first worker spawned will check to
# see if an .oldbin pidfile exists. If so, this means we've just booted up
# a new Unicorn and need to tell the old one that it can now die. To do so
# we send it a QUIT.
#
# Using this method we get 0 downtime deploys.
old_pid = '/tmp/pids/unicorn.pid.oldbin'
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream unicorn {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 8081 default deferred;
server_name localhost;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering on;
proxy_pass http://192.168.103.212:3000;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
搞的火大~中间还跑去弄 apache 试试
unicorn 启动貌似是正常 pig 和 socket 都正常 但浏览器访问就是打不开
[root@mysql-test-woody www]# bundle exec unicorn_rails -c config/unicorn.rb -E production -D
[root@mysql-test-woody www]# ps aux | grep
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
[root@mysql-test-woody www]# ps aux | grep 'unicorn'
root 9510 32.1 3.6 45072 37368 ? Sl 15:06 0:04 unicorn_rails master -c config/unicorn.rb -E production -D
git 9514 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[0] -c config/unicorn.rb -E production -D
git 9517 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[1] -c config/unicorn.rb -E production -D
git 9520 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[2] -c config/unicorn.rb -E production -D
git 9523 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[3] -c config/unicorn.rb -E production -D
git 9526 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[4] -c config/unicorn.rb -E production -D
git 9529 0.1 3.4 45116 35776 ? Sl 15:06 0:00 unicorn_rails worker[5] -c config/unicorn.rb -E production -D
root 9543 0.0 0.0 3892 676 pts/1 R+ 15:06 0:00 grep unicorn