Saya mencoba menerapkan aplikasi Sinatra ke server saya dengan Unicorn. Namun ketika saya mencoba menjalankan unicorn -c path/to/unicorn.rb -E development -D
saya mendapat kesalahan master failed to start, check stderr log for details
. Ini adalah file log stderr:
FATAL -- : error adding listener addr=../rails/tmp/sockets/unicorn.sock /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/socket_helper.rb:167:in `bind_listen': Don't know how to bind: ../rails/tmp/sockets/unicorn.sock (Argum$
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:255:in `listen'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:801:in `block in bind_new_listeners!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:801:in `each'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:801:in `bind_new_listeners!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:146:in `start'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Juga, saya membuat folder unicorn tmp,log,tmp/pid,tmp/sockets di dalam folder aplikasi saya dan membuat unicorn.conf dan unicorn.rb sebagai berikut:
unicorn.rb
# set path to app that will be used to configure unicorn,
# note the trailing slash in this example
@dir = "./"
worker_processes 2
working_directory @dir
timeout 30
# Specify path to socket unicorn listens to,
# we will use this in our nginx.conf later
listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64
# Set process id path
pid "#{@dir}tmp/pids/unicorn.pid"
# Set log file paths
stderr_path "#{@dir}log/unicorn.stderr.log"
stdout_path "#{@dir}log/unicorn.stdout.log"
unicorn.conf
listen "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "./"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"
Saya berasumsi masalahnya mungkin didasarkan pada nginx. jadi saya mengedit nginx.conf sebagai berikut:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/xml text/css text/comma-separated-values;
upstream app_server { server 127.0.0.1:8080 fail_timeout=0; }
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream unicorn_server {
server unix:/home/rails/tmp/sockets/unicorn.sock
fail_timeout=0;
}
}
Seperti yang terlihat dari log, masalahnya didasarkan pada file unicorn.sock. Namun ketika saya mencari di Google masalah tentang "Tidak tahu cara mengikat" tidak ada solusi yang dapat saya temukan. Butuh saran. Terimakasih atas bantuannya.