Listening UNIX socket is not deleted when stopping Unicorn?

Eric Wong normalperson at yhbt.net
Sun Dec 27 22:15:46 EST 2009


Iñaki Baz Castillo <ibc at aliax.net> wrote:
> Hi, I listen into an UNIX socket but after stopping Unicorn the socket
> is not removed. Is it the expected behavior?

Yes.

Otherwise it's subject to race conditions where the socket
owned by a new/replacement process gets its socket unlinked.

Currently Unicorn unlinks any existing socket on the FS before
attempting to bind to it for the following reasons:

* I consider this less error-prone, especially when people aren't
  storing sockets in a directory that's cleared on reboots (like /tmp).

* This can also be desirable behavior since it can be used to do
  transparent upgrades/binary replacements in cases where it's less
  convenient to use USR2+QUIT,  if you're switching between Ruby
  installations for example.

> This causes problem of permissions when changing the user/group
> running the workers (as they cannot remove the old socket with
> different owner).

Since there's absolutely no point in running Unicorn on port 80/443, you
should just avoid user switching entirely since it'll significantly
simplify your setup(s).

-- 
Eric Wong


More information about the mongrel-unicorn mailing list