In Files

Parent

Methods

Unicorn::Worker

This class and its members can be considered a stable interface and will not change in a backwards-incompatible fashion between releases of Unicorn. You may need to access it in the before_fork/after_fork hooks. See the Unicorn::Configurator RDoc for examples.

Public Instance Methods

==(other_nr) click to toggle source

worker objects may be compared to just plain numbers

     # File lib/unicorn.rb, line 169
169:       def ==(other_nr)
170:         self.nr == other_nr
171:       end
user(user, group = nil) click to toggle source

Changes the worker process to the specified user and group This is only intended to be called from within the worker process from the after_fork hook. This should be called in the after_fork hook after any priviledged functions need to be run (e.g. to set per-worker CPU affinity, niceness, etc)

Any and all errors raised within this method will be propagated directly back to the caller (usually the after_fork hook. These errors commonly include ArgumentError for specifying an invalid user/group and Errno::EPERM for insufficient priviledges

     # File lib/unicorn.rb, line 183
183:       def user(user, group = nil)
184:         # we do not protect the caller, checking Process.euid == 0 is
185:         # insufficient because modern systems have fine-grained
186:         # capabilities.  Let the caller handle any and all errors.
187:         uid = Etc.getpwnam(user).uid
188:         gid = Etc.getgrnam(group).gid if group
189:         Unicorn::Util.chown_logs(uid, gid)
190:         tmp.chown(uid, gid)
191:         if gid && Process.egid != gid
192:           Process.initgroups(user, gid)
193:           Process::GID.change_privilege(gid)
194:         end
195:         Process.euid != uid and Process::UID.change_privilege(uid)
196:         self.switched = true
197:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.