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
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
19 Users of GNU-based systems (such as GNU/Linux) usually have GNU make
20 installed as "make" instead of "gmake".
22 Running the entire test suite with 4 tests in parallel:
26 Running just one unit test:
28 gmake test/unit/test_http_parser.rb
30 Running just one test case in a unit test:
32 gmake test/unit/test_http_parser.rb--test_parse_simple.n
36 We strive to write as little code as possible while still maintaining
37 readability. However, readability and flexibility may be sacrificed for
38 performance in hot code paths. For Ruby, less code generally means
41 Memory allocation should be minimized as much as practically possible.
42 Buffers for IO#readpartial are preallocated in the hot paths to avoid
43 building up garbage. Hash assignments use frozen strings to avoid the
44 duplication behind-the-scenes.
46 We spend as little time as possible inside signal handlers and instead
47 defer handling them for predictability and robustness. Most of the
48 Unix-specific things are in the Unicorn::HttpServer class. Unix systems
49 programming experience will come in handy (or be learned) here.
53 Please wrap documentation at 72 characters-per-line or less (long URLs
54 are exempt) so it is comfortably readable from terminals.
56 When referencing mailing list posts, use
57 <tt>https://yhbt.net/unicorn-public/$MESSAGE_ID/</tt> if possible
58 since the Message-ID remains searchable even if a particular site
61 === Ruby/C Compatibility
63 We target C Ruby 2.0 and later. We need the Ruby
64 implementation to support fork, exec, pipe, UNIX signals, access to
65 integer file descriptors and ability to use unlinked files.
67 All of our C code is OS-independent and should run on compilers
68 supported by the versions of Ruby we target.
70 === Ragel Compatibility
72 We target the latest released version of Ragel and will update our code
73 to keep up with new releases. Packaged tarballs and gems include the
74 generated source code so they will remain usable if compatibility is
79 Contributions are welcome in the form of patches, pull requests, code
80 review, testing, documentation, user support or any other feedback is
81 welcome. The mailing list is the central coordination point for all
82 user and developer feedback and bug reports.
84 === Submitting Patches
86 Follow conventions already established in the code and do not exceed 80
89 Inline patches (from "git format-patch -M") to the mailing list are
90 preferred because they allow code review and comments in the reply to
93 We will adhere to mostly the same conventions for patch submissions as
95 {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
97 distributed with git on on patch submission guidelines to follow. Just
98 don't email the git mailing list or maintainer with Unicorn patches :)
102 You can build the Unicorn gem with the following command:
106 == Running Development Versions
108 It is easy to install the contents of your git working directory: