diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-03-01 08:47:40 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-03-01 08:47:40 +0000 |
commit | 45e89c0fed05396652bd3061b9b4f0814dc7d37d (patch) | |
tree | 5b7742de6a4702f4d979356e2bb561fce5515c52 /lib/unicorn/configurator.rb | |
parent | e37d8d0c6355e48fd6d2627313b9003a160f27fc (diff) | |
download | unicorn-45e89c0fed05396652bd3061b9b4f0814dc7d37d.tar.gz |
Allowing the "user" directive outside of after_fork reduces the cognitive overhead for folks that do not need the complexity of *_fork hooks. Using Worker#user remains supported as it offers fine-grained control of user switching.
Diffstat (limited to 'lib/unicorn/configurator.rb')
-rw-r--r-- | lib/unicorn/configurator.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index b586c67..64a25e3 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -336,6 +336,17 @@ module Unicorn HttpServer::START_CTX[:cwd] = ENV["PWD"] = path end + # Runs worker processes as the specified +user+ and +group+. + # The master process always stays running as the user who started it. + # This switch will occur after calling the after_fork hook, and only + # if the Worker#user method is not called in the after_fork hook + def user(user, group = nil) + # raises ArgumentError on invalid user/group + Etc.getpwnam(user) + Etc.getgrnam(group) if group + set[:user] = [ user, group ] + end + # expands "unix:path/to/foo" to a socket relative to the current path # expands pathnames of sockets if relative to "~" or "~username" # expands "*:port and ":port" to "0.0.0.0:port" |