Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Can't use sockets with rails #44

Closed
saiko-chriskun opened this Issue · 10 comments

4 participants

Chris Bolton Evan Phoenix Oleksandr Skrypnyk Kristijan Sedlak
Chris Bolton

rails s puma works fine, but I get the following when appending -b unix://tmp/sockets/puma.sock:

=> Booting Puma
=> Rails 3.2.2 application starting in development on http://unix://tmp/sockets/puma.sock:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 0.9.4 starting...

  • Min threads: 0, max threads: 16
  • Listening on tcp://unix://tmp/sockets/puma.sock:3000 Exiting /usr/lib/ruby/gems/1.9.1/gems/puma-0.9.4/lib/puma/server.rb:103:in `initialize': getaddrinfo: Name or service not known (SocketError)
Chris Bolton

huh ok so I tried puma -b unix://tmp/sockets/puma.sock config.ru, but doesn't seem to be playing well with nginx, just gives me a bad gateway error. works fine if I don't use a socket and just use a custom port.

Chris Bolton

and my nginx setup works fine with unicorn's sockets.

Evan Phoenix
Owner

Was the first attempt calling puma via "rails server"? It looks like it got heavily confused because it's got a port number in there too.

I did just test it using nginx and it seems to work fine. What nginx configuration do you have it? Does the request show up in puma's log at all?

Oleksandr Skrypnyk

+1
also tried to pair it with nginx, but all I've got is "Bad Gateway"
this configuration works well with Unicorn, but not with Puma

nginx.conf:

upstream puma {
  server unix://tmp/puma.sock fail_timeout=0;
}

config/puma.rb:

bind "unix:///tmp/puma.sock"
pidfile "/tmp/puma.pid"

running as:

~$ puma -C ./config/puma.rb config.ru
Puma 1.0.0 starting...
* Min threads: 0, max threads: 16
* Listening on unix:///tmp/puma.sock
Use Ctrl-C to stop
Evan Phoenix
Owner

I'm still unable to reproduce this issue. What is in config.ru?

Oleksandr Skrypnyk

Just default Rails app

require ::File.expand_path('../config/environment',  __FILE__)
run TestApp::Application
Evan Phoenix
Owner

What version of nginx are you testing against? Does anything render?

Oleksandr Skrypnyk

nginx/1.0.13

Oops, sorry, my bad. nginx logs shows me: *1 connect() to unix://tmp/puma.sock failed (13: Permission denied) while connecting to upstream

chmod a+rw /tmp/puma.sock does the trick

Evan Phoenix
Owner

Oh interesting! So it was a permission problem. I'll investigate the proper way to set the perms of a unix socket.

Evan Phoenix evanphx closed this in 3dd7049
Kristijan Sedlak

Related to this #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.