JezK
Edit File: page-Sandbox.ri
U:RDoc::TopLevel[ i I"Sandbox:ETcRDoc::Parser::Simpleo:RDoc::Markup::Document:@parts[?S:RDoc::Markup::Heading: leveli: textI";Tips for using unicorn with Sandbox installation tools;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[ I"LSince unicorn includes executables and is usually used to start a Ruby ;TI"Lprocess, there are certain caveats to using it with tools that sandbox ;TI"$RubyGems installations such as ;TI"&{Bundler}[http://bundler.io/] or ;TI"5{Isolate}[https://github.com/jbarnette/isolate].;T@ S; ; i;I"General deployment;T@ o; ;[I"MIf you're sandboxing your unicorn installation and using Capistrano (or ;TI"Qsimilar), it's required that you sandbox your RubyGems in a per-application ;TI"Cshared directory that can be used between different revisions.;T@ o; ;[I"Junicorn will stash its original command-line at startup for the USR2 ;TI"Jupgrades, and cleaning up old revisions will cause revision-specific ;TI"Kinstallations of unicorn to go missing and upgrades to fail. If you ;TI"Hfind yourself in this situation and can't afford downtime, you can ;TI"Koverride the existing unicorn executable path in the config file like ;TI" this:;T@ o:RDoc::Markup::Verbatim;[I"EUnicorn::HttpServer::START_CTX[0] = "/some/path/to/bin/unicorn" ;T:@format0o; ;[I"JThen use HUP to reload, and then continue with the USR2+QUIT upgrade ;TI"sequence.;T@ o; ;[I"LEnvironment variable pollution when exec-ing a new process (with USR2) ;TI"Lis the primary issue with sandboxing tools such as Bundler and Isolate.;T@ S; ; i;I"Bundler;T@ S; ; i;I"Running;T@ o; ;[I"LIf you're bundling unicorn, use "bundle exec unicorn" (or "bundle exec ;TI"Lunicorn_rails") to start unicorn with the correct environment variables;T@ o; ;[I"cref: https://bogomips.org/unicorn-public/9ECF07C4-5216-47BE-961D-AFC0F0C82060@internetfamo.us/;T@ o; ;[I"LOtherwise (if you choose to not sandbox your unicorn installation), we ;TI"4expect the tips for Isolate (below) apply, too.;T@ S; ; i;I",RUBYOPT pollution from SIGUSR2 upgrades;T@ o; ;[I"7This is no longer be an issue as of bundler 0.9.17;T@ o; ;[I" ref: ;TI"\https://bogomips.org/unicorn-public/8FC34B23-5994-41CC-B5AF-7198EF06909E@tramchase.com/;T@ S; ; i;I"(BUNDLE_GEMFILE for Capistrano users;T@ o; ;[I"MYou may need to set or reset the BUNDLE_GEMFILE environment variable in ;TI"the before_exec hook:;T@ o;;[I"before_exec do |server| ;TI"> ENV["BUNDLE_GEMFILE"] = "/path/to/app/current/Gemfile" ;TI" end ;T;0S; ; i;I"Other ENV pollution issues;T@ o; ;[I"NIf you're using an older Bundler version (0.9.x), you may need to set or ;TI"Dreset GEM_HOME, GEM_PATH and PATH environment variables in the ;TI"Fbefore_exec hook as illustrated by https://gist.github.com/534668;T@ S; ; i;I"9Ruby 2.0.0 close-on-exec and SIGUSR2 incompatibility;T@ o; ;[ I"MRuby 2.0.0 enforces FD_CLOEXEC on file descriptors by default. unicorn ;TI"Jhas been prepared for this behavior since unicorn 4.1.0, and bundler ;TI"Cneeds the "--keep-file-descriptors" option for "bundle exec": ;TI"-http://bundler.io/man/bundle-exec.1.html;T@ S; ; i;I"Isolate;T@ S; ; i;I"Running;T@ o; ;[ I"AInstalling "unicorn" as a system-wide Rubygem and using the ;TI"Eisolate gem may cause issues if you're using any of the bundled ;TI"Eapplication-level libraries in unicorn/app/* (for compatibility ;TI"?with CGI-based applications, Rails <= 2.2.2, or ExecCgi). ;TI"<For now workarounds include doing one of the following:;T@ o:RDoc::Markup::List: @type:NUMBER:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"?Isolating unicorn, setting GEM_HOME to your Isolate path, ;TI"Band running the isolated version of unicorn. You *must* set ;TI"GGEM_HOME before running your isolated unicorn install in this way.;T@ o;;0;[o; ;[I"EInstalling the same version of unicorn as a system-wide Rubygem ;TI"%*and* isolating unicorn as well.;T@ o;;0;[o; ;[I"FExplicitly setting RUBYLIB or $LOAD_PATH to include any gem path ;TI"(where the unicorn gem is installed ;TI"=(e.g. /usr/lib/ruby/gems/1.9.3/gems/unicorn-VERSION/lib);T@ S; ; i;I",RUBYOPT pollution from SIGUSR2 upgrades;T@ o; ;[I"LIf you are using Isolate, using Isolate 2.x is strongly recommended as ;TI".environment modifications are idempotent.;T@ o; ;[ I"KIf you are stuck with 1.x versions of Isolate, it is recommended that ;TI"Lyou disable it with the <tt>before_exec</tt> hook prevent the PATH and ;TI"IRUBYOPT environment variable modifications from propagating between ;TI"*upgrades in your Unicorn config file:;T@ o;;[I"before_exec do |server| ;TI" Isolate.disable ;TI"end;T;0: @file@:0@omit_headings_from_table_of_contents_below0