Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

prefixing PATH/RUBYOPT makes Unicorns weep #259

Closed
jamiew opened this issue Apr 7, 2010 · 3 comments
Closed

prefixing PATH/RUBYOPT makes Unicorns weep #259

jamiew opened this issue Apr 7, 2010 · 3 comments

Comments

@jamiew
Copy link
Contributor

jamiew commented Apr 7, 2010

We recently ran into a major production issue with our nginx+unicorn setup after upgrading from bundler08. After some time our unicorn processes would become completely unresponsive to USR2 signals and would need to be forcibly restarted.

We tracked it down to an issue recently discussed on the Unicorn list:
http://www.mail-archive.com/mongrel-unicorn@rubyforge.org/msg00273.html

Lowdown: unicorn does not clear it's PATH/RUBYOPT environment variables on re-exec, and thus unicorn+bundler+capistrano accrues gems from every deployed version (!!) until a long-lived unicorn becomes sad & tired and must be sent to the glue factory.

Forcibly clearing the environment in one's unicorn configuration solves the issue:

stash_env = %w(PATH RUBYOPT).map { |x| [ x, ENV[x] ] }
before_exec do |_|
  stash_env.each { |(k,v)| ENV[k] = v }
end

...but per the above thread Eric is opting not to patch this in unicorn itself, since it can be desirable to maintain the environment between re-execs. So it would be good to address this in bundler, either with code or documentation.

@indirect
Copy link
Member

indirect commented Apr 7, 2010

seems like a good solution would be to simply not prepend to PATH or RUBYOPT if the entries are already present. sound reasonable?

@indirect
Copy link
Member

indirect commented Apr 7, 2010

Committed in 589ec4e.

@jamiew
Copy link
Contributor Author

jamiew commented Apr 7, 2010

Awesome, thanks indirect.
I'll post this to the Unicorn list as well.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants