Skip to content

Commit

Permalink
doc: update documentation for systemd + PrivateTmp users
Browse files Browse the repository at this point in the history
The PrivateTmp feature of systemd breaks the usage of /tmp for the
shared Unix domain socket between nginx and unicorn, so discourage the
use of /tmp in that case.

While we're at it, use consistent paths for everything and use an
obviously intended-for-user-customization "/path/to" prefix instead
of "/tmp"

ML-Ref: CAKLVLx_t+9zWMhquMWDfStrxS7xrNoGmN0ZDsjSCUE=VxU+oyQ@mail.gmail.com
Reported-by: David Wilkins <dwilkins@conecuh.com>
  • Loading branch information
Eric Wong committed Apr 5, 2013
1 parent 04bcc14 commit 9f846a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions examples/nginx.conf
Expand Up @@ -24,8 +24,8 @@ user nobody nogroup; # for systems with a "nogroup"
# user nobody nobody; # for systems with "nobody" as a group instead

# Feel free to change all paths to suite your needs here, of course
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
pid /path/to/nginx.pid;
error_log /path/to/nginx.error.log;

events {
worker_connections 1024; # increase if you have lots of clients
Expand All @@ -42,7 +42,7 @@ http {
default_type application/octet-stream;

# click tracking!
access_log /tmp/nginx.access.log combined;
access_log /path/to/nginx.access.log combined;

# you generally want to serve static files with nginx since neither
# Unicorn nor Rainbows! is optimized for it at the moment
Expand Down Expand Up @@ -74,7 +74,7 @@ http {
# single worker for timing out).

# for UNIX domain socket setups:
server unix:/tmp/.sock fail_timeout=0;
server unix:/path/to/.unicorn.sock fail_timeout=0;

# for TCP setups, point these to your backend servers
# server 192.168.0.7:8080 fail_timeout=0;
Expand Down
2 changes: 1 addition & 1 deletion examples/unicorn.conf.rb
Expand Up @@ -25,7 +25,7 @@

# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen "/path/to/.unicorn.sock", :backlog => 64
listen 8080, :tcp_nopush => true

# nuke workers after 30 seconds instead of 60 seconds (the default)
Expand Down
10 changes: 8 additions & 2 deletions lib/unicorn/configurator.rb
Expand Up @@ -188,7 +188,7 @@ def before_exec(*args, &block)
# # on nginx upstream configuration:
# upstream unicorn_backend {
# # for UNIX domain socket setups:
# server unix:/path/to/unicorn.sock fail_timeout=0;
# server unix:/path/to/.unicorn.sock fail_timeout=0;
#
# # for TCP setups
# server 192.168.0.7:8080 fail_timeout=0;
Expand Down Expand Up @@ -229,9 +229,15 @@ def listeners(addresses) # :nodoc:
#
# listen 3000 # listen to port 3000 on all TCP interfaces
# listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface
# listen "/tmp/.unicorn.sock" # listen on the given Unix domain socket
# listen "/path/to/.unicorn.sock" # listen on the given Unix domain socket
# listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
#
# When using Unix domain sockets, be sure:
# 1) the path matches the one used by nginx
# 2) uses the same filesystem namespace as the nginx process
# For systemd users using PrivateTmp=true (for either nginx or unicorn),
# this means Unix domain sockets must not be placed in /tmp
#
# The following options may be specified (but are generally not needed):
#
# [:backlog => number of clients]
Expand Down

0 comments on commit 9f846a2

Please sign in to comment.