unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Russell Jennings <violentpurr@gmail.com>
Cc: unicorn-public@bogomips.org
Subject: Re: $USER and $HOME shell variables not set
Date: Fri, 27 Mar 2015 18:34:15 +0000	[thread overview]
Message-ID: <20150327183415.GA32272@dcvr.yhbt.net> (raw)
In-Reply-To: <E6EDFE8D-87EB-473D-B189-B282D17B8324@gmail.com>

Russell Jennings <violentpurr@gmail.com> wrote:
> Hello,
> 
> I am running into some issues with these variables being set - since I
> am spawning a script from a unicorn worker (via a rails controller) I
> figured I’d ask here. 
> 
> Here is the stackoverflow with the full background:
> http://stackoverflow.com/questions/29233181/why-is-envhome-nil-in-my-rake-task
> 
> in short: does unicorn have anything to do with $HOME or $USER not
> being defined?

Nope, unicorn itself does not change these variables.  We only set
UNICORN_FD (for SIGUSR2 upgrades), PWD (if working_directory is used).

Your init system may change users and clobber these options via
sudo/su/env and similar wrappers, so I think it has to do with how
you're starting unicorn.  If you're using sudo anywhere, the env_*
options from the sudoers files will also affect which envs get
clobbered/preserved/added.

> From what I can tell, that its unicorn is the only
> thing thats different versus running the same ruby via a rails console
> (which does indeed set those shell variables correctly)
> 
> in no mans land, so any hep or insight would be greatly appreciated. 

Can you add something to log the contents of ENV.inspect to
a log file.  Perhaps something like:

	Rails.logger.debug("env: #{ENV.inspect}")

It would also be helpful to show the snippet of code from where you're
running Rake in case you're accidentally setting an option wrong.


Under Linux, you can also inspect the original environment of any running
process from /proc/$PID/environ  In most cases/kernel versions, it won't
keep up with env changes once a process is running.
I use tr to replace '\0' with '\n' (newline) to help with readability

	tr '\0' '\n' </proc/$PID/environ

      reply	other threads:[~2015-03-27 18:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27 14:32 Russell Jennings
2015-03-27 18:34 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150327183415.GA32272@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=unicorn-public@bogomips.org \
    --cc=violentpurr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this inbox:

	../../unicorn.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).