ruby-on-railsnginxthin

Thin start with error (`start_unix_server': no unix-domain acceptor (RuntimeError))


I deployed a rails app to nginx, thin using capistrano (rails 4, ruby 2.1.2, thin 1.6.2, capistrano 2.1.5). I started thin by thin start command. And view some error on this file thin.log. Can anyone show me how to fix that?

Thank you very much!

thin.yml

 pid: /home/deploy/myapp/pids/thin.pid
 port: 3000
 timeout: 30
 wait: 30
 log: log/thin.log
 max_conns: 1024
 require: []
 environment: production
 max_persistent_conns: 512
 threaded: true
 no-epoll: true
 daemonize: true
 socket: /home/deploy/myapp/sockets/thin.sock
 chdir: /home/deploy/myapp/current
 address: 0.0.0.0

/etc/nginx/sites-availabel/default

upstream myapp{
        server 127.0.0.1:3000;
        server 127.0.0.1:3001;
        server 127.0.0.1:3002;
}
server {
        listen   80;
        server_name _;
        character utf-8;


        access_log /home/deploy/myapp/log/access.log;
        error_log /home/deploy/myapp/log/error.log;
        root     /home/deploy/myapp/current/public;

        location / {
                proxy_pass http://127.0.0.1:3000;
        }

}

thin.log

Writing PID to /home/deploy/myapp/pids/thin.pid
Using rack adapter
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on /home/deploy/myapp/sockets/thin.sock, CTRL+C to stop
Exiting!
/home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:528:in `start_unix_server': no unix-domain acceptor (RuntimeError)
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:528:in `start_server'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:548:in `start_unix_domain_server'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/unix_server.rb:19:in `connect'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/base.rb:63:in `block in start'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
    from /home/deploy/.rvm/gems/ruby-2.1.2/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
    from /home/deploy/.rvm/gems/ruby-2.1.2/bin/thin:23:in `load'
    from /home/deploy/.rvm/gems/ruby-2.1.2/bin/thin:23:in `<main>'
    from /home/deploy/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /home/deploy/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Solution

  • Here is what my nginx looks like using thin. Maybe it can help.

       upstream thin_server {
              server 0.0.0.0:8080 fail_timeout=0;
            }
    
            server {
                    listen   80 default;
                    root /home/example/public;
                    server_name example.com www.example.com;
                    index index.htm index.html;
    
    
                    location / {
                            try_files $uri/index.html $uri.html $uri @app;
                    }
    
                    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mp3|flv|mpeg|avi)$ {
                                    try_files $uri @app;
                            }
    
                     location @app {
                            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                            proxy_set_header Host $http_host;
                            proxy_redirect off;
                            proxy_pass http://thin_server;
                }
    
                error_page 500 502 503 504 /500.html;
                client_max_body_size 4G;
                keepalive_timeout 10;
    }