vagrant+unicornで立ち上がらない件
vagrantでホストのディスクをマウントしているところに
railsのコードを置いて、unicornを立ち上げたら.sockファイルが作れなくてエラーになった。
config/unicorn.rb の .sock ファイルのパスを /tmp 配下に変えたらちゃんと動いた
/etc/nginx/conf.d/rails.conf
upstream unicorn { server unix:/tmp/unicorn.sock; } server { listen 8080; server_name localhost; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /home/vagrant/myapp/public; client_max_body_size 100m; error_page 404 /404.html; error_page 500 502 503 504 /500.html; try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn; } }
{rails_root}/config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) timeout 15 preload_app true listen '/tmp/unicorn.sock' pid '/tmp/unicorn.pid' before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end stderr_path File.expand_path('log/unicorn_stderr.log', ENV['RAILS_ROOT']) stdout_path File.expand_path('log/unicorn_stdout.log', ENV['RAILS_ROOT'])