Home directory for workers

Eric Wong normalperson at yhbt.net
Tue Oct 11 04:16:01 EDT 2011


neil at dist.ro wrote:
> When unicorn is started as the root user and the worker processes run
> as as an unprivileged user because of the "user" option in
> unicorn.conf then the home directory of the worker processes is still
> "/root".  This causes trouble with GPGME at least, which expects to
> find encryption keys in the user's home directory.

You mean the ENV["HOME"] value?  This typically isn't changed when
changing privileges in other daemons like nginx.  Changing ENV["HOME"]
automatically inside unicorn has the potential to break existing setups
badly, so it won't be done.

However, you can set it in your after_fork hook (or anywhere else in
your unicorn config file)

  after_fork do |server,worker|
    ENV["HOME"] = "/home/user"
  end

You can even set it in the shell when starting unicorn:

  HOME=/home/user unicorn -c unicorn.conf.rb


More information about the mongrel-unicorn mailing list