unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob d1011064a88f41774846380a7d6811c1ad06203f 3232 bytes (raw)
$ git show 1.1.x-stable:Sandbox	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
= Tips for using \Unicorn with Sandbox installation tools

Since unicorn includes executables and is usually used to start a Ruby
process, there are certain caveats to using it with tools that sandbox
RubyGems installations such as
{Bundler}[http://github.com/carlhuda/bundler] or
{Isolate}[http://github.com/jbarnette/isolate].

== General deployment

If you're sandboxing your unicorn installation and using Capistrano (or
similar), it's required that you sandbox your RubyGems in a per-application
shared directory that can be used between different revisions.

unicorn will stash its original command-line at startup for the USR2
upgrades, and cleaning up old revisions will cause revision-specific
installations of unicorn to go missing and upgrades to fail.   If you
find yourself in this situation and can't afford downtime, you can
override the existing unicorn executable path in the config file like
this:

        Unicorn::HttpServer::START_CTX[0] = "/some/path/to/bin/unicorn"

Then use HUP to reload, and then continue with the USR2+QUIT upgrade
sequence.

Environment variable pollution when exec-ing a new process (with USR2)
is the primary issue with sandboxing tools such as Bundler and Isolate.

== Bundler

=== Running

If you're bundling unicorn, use "bundle exec unicorn" (or "bundle exec
unicorn_rails") to start unicorn with the correct environment variables

ref: http://mid.gmane.org/9ECF07C4-5216-47BE-961D-AFC0F0C82060@internetfamo.us

Otherwise (if you choose to not sandbox your unicorn installation), we
expect the tips for Isolate (below) apply, too.

=== RUBYOPT pollution from SIGUSR2 upgrades

This is no longer be an issue as of bundler 0.9.17

ref: http://mid.gmane.org/8FC34B23-5994-41CC-B5AF-7198EF06909E@tramchase.com

=== Other ENV pollution issues

You may need to set or reset BUNDLE_GEMFILE, GEM_HOME, GEM_PATH and PATH
environment variables in the before_exec hook as illustrated by
http://gist.github.com/534668

== Isolate

=== Running

Installing "unicorn" as a system-wide Rubygem and using the
isolate gem may cause issues if you're using any of the bundled
application-level libraries in unicorn/app/* (for compatibility
with CGI-based applications, Rails <= 2.2.2, or ExecCgi).
For now workarounds include doing one of the following:

1. Isolating unicorn, setting GEM_HOME to your Isolate path,
   and running the isolated version of unicorn.  You *must* set
   GEM_HOME before running your isolated unicorn install in this way.

2.  Installing the same version of unicorn as a system-wide Rubygem
    *and* isolating unicorn as well.

3. Explicitly setting RUBYLIB or $LOAD_PATH to include any gem path
   where the unicorn gem is installed
   (e.g. /usr/lib/ruby/gems/1.9.1/gems/unicorn-VERSION/lib)

=== RUBYOPT pollution from SIGUSR2 upgrades

If you are using Isolate, using Isolate 2.x is strongly recommended as
environment modifications are idempotent.

If you are stuck with 1.x versions of Isolate, it is recommended that
you disable it with the <tt>before_exec</tt> hook prevent the PATH and
RUBYOPT environment variable modifications from propagating between
upgrades in your Unicorn config file:

        before_exec do |server|
          Isolate.disable
        end

git clone https://yhbt.net/unicorn.git