remove old inetd+git examples and exec_cgi
[unicorn.git] / HACKING
blob9b4da1b51a88170734cf036ab2e9ea792458aa9e
1 = Unicorn Hacker's Guide
3 == Polyglot Infrastructure
5 Like Mongrel, we use Ruby where it makes sense, and Ragel with C where
6 it helps performance.  All of the code that actually runs your Rack
7 application is written Ruby, Ragel or C.
9 As far as tests and documentation goes, we're not afraid to embrace Unix
10 and use traditional Unix tools where they make sense and get the job
11 done.
13 === Tests
15 Tests are good, but slow tests make development slow, so we make tests
16 faster (in parallel) with GNU make (instead of Rake) and avoiding
17 RubyGems.
19 Users of GNU-based systems (such as GNU/Linux) usually have GNU make
20 installed as "make" instead of "gmake".
22 Since we don't load RubyGems by default, loading Rack properly requires
23 setting up RUBYLIB to point to where Rack is located.  Not loading
24 RubyGems drastically lowers the time to run the full test suite.  You
25 may setup a "local.mk" file in the top-level working directory to setup
26 your RUBYLIB and any other environment variables.  A "local.mk.sample"
27 file is provided for reference.
29 Running the entire test suite with 4 tests in parallel:
31   gmake -j4 check
33 Running just one unit test:
35   gmake test/unit/test_http_parser.rb
37 Running just one test case in a unit test:
39   gmake test/unit/test_http_parser.rb--test_parse_simple.n
41 === HttpServer
43 We strive to write as little code as possible while still maintaining
44 readability.  However, readability and flexibility may be sacrificed for
45 performance in hot code paths.  For Ruby, less code generally means
46 faster code.
48 Memory allocation should be minimized as much as practically possible.
49 Buffers for IO#readpartial are preallocated in the hot paths to avoid
50 building up garbage.  Hash assignments use frozen strings to avoid the
51 duplication behind-the-scenes.
53 We spend as little time as possible inside signal handlers and instead
54 defer handling them for predictability and robustness.  Most of the
55 Unix-specific things are in the Unicorn::HttpServer class.  Unix systems
56 programming experience will come in handy (or be learned) here.
58 === Documentation
60 Due to the lack of RDoc-to-manpage converters we know about, we're
61 writing manpages in Markdown and converting to troff/HTML with Pandoc.
63 Please wrap documentation at 72 characters-per-line or less (long URLs
64 are exempt) so it is comfortably readable from terminals.
66 When referencing mailing list posts, use
67 "http://bogomips.org/unicorn-public/m/$MESSAGE_ID.html" if possible
68 since the Message-ID remains searchable even if a particular site
69 becomes unavailable.
71 === Ruby/C Compatibility
73 We target Ruby 1.8.6+, 1.9 and will target Rubinius as it becomes
74 production-ready.  We need the Ruby implementation to support fork,
75 exec, pipe, UNIX signals, access to integer file descriptors and
76 ability to use unlinked files.
78 All of our C code is OS-independent and should run on compilers
79 supported by the versions of Ruby we target.
81 === Ragel Compatibility
83 We target the latest released version of Ragel and will update our code
84 to keep up with new releases.  Packaged tarballs and gems include the
85 generated source code so they will remain usable if compatibility is
86 broken.
88 == Contributing
90 Contributions are welcome in the form of patches, pull requests, code
91 review, testing, documentation, user support or any other feedback is
92 welcome.  The mailing list is the central coordination point for all
93 user and developer feedback and bug reports.
95 === Submitting Patches
97 Follow conventions already established in the code and do not exceed 80
98 characters per line.
100 Inline patches (from "git format-patch -M") to the mailing list are
101 preferred because they allow code review and comments in the reply to
102 the patch.
104 We will adhere to mostly the same conventions for patch submissions as
105 git itself.  See the
106 {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
107 document
108 distributed with git on on patch submission guidelines to follow.  Just
109 don't email the git mailing list or maintainer with Unicorn patches :)
111 == Building a Gem
113 In order to build the gem, you must install the following components:
115  * olddoc (RubyGem)
116  * pandoc
118 You can build the Unicorn gem with the following command:
120   gmake gem
122 == Running Development Versions
124 It is easy to install the contents of your git working directory:
126 Via RubyGems (RubyGems 1.3.5+ recommended for prerelease versions):
128   gmake install-gem
130 Without RubyGems (via setup.rb):
132   gmake install
134 It is not at all recommended to mix a RubyGems installation with an
135 installation done without RubyGems, however.