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 Ragel may be dropped in favor of a picohttpparser-based one in the future.
11 As far as tests and documentation goes, we're not afraid to embrace Unix
12 and use traditional Unix tools where they make sense and get the job
17 Tests are good, but slow tests make development slow, so we make tests
18 faster (in parallel) with GNU make (instead of Rake) and avoiding
21 New tests are written in Perl 5 and use TAP <https://testanything.org/>
22 to ensure stability and immunity from Ruby incompatibilities.
24 Users of GNU-based systems (such as GNU/Linux) usually have GNU make
25 installed as "make" instead of "gmake".
27 Running the entire test suite with 4 tests in parallel:
31 Running just one unit test:
33 gmake test/unit/test_http_parser.rb
35 Running just one test case in a unit test:
37 gmake test/unit/test_http_parser.rb--test_parse_simple.n
41 We strive to write as little code as possible while still maintaining
42 readability. However, readability and flexibility may be sacrificed for
43 performance in hot code paths. For Ruby, less code generally means
46 Memory allocation should be minimized as much as practically possible.
47 Buffers for IO#readpartial are preallocated in the hot paths to avoid
48 building up garbage. Hash assignments use frozen strings to avoid the
49 duplication behind-the-scenes.
51 We spend as little time as possible inside signal handlers and instead
52 defer handling them for predictability and robustness. Most of the
53 Unix-specific things are in the Unicorn::HttpServer class. Unix systems
54 programming experience will come in handy (or be learned) here.
58 Please wrap documentation at 72 characters-per-line or less (long URLs
59 are exempt) so it is comfortably readable from terminals.
61 When referencing mailing list posts, use
62 <tt>https://yhbt.net/unicorn-public/$MESSAGE_ID/</tt> if possible
63 since the Message-ID remains searchable even if a particular site
66 === Ruby/C Compatibility
68 We target C Ruby 2.5 and later. We need the Ruby
69 implementation to support fork, exec, pipe, UNIX signals, access to
70 integer file descriptors and ability to use unlinked files.
72 All of our C code is OS-independent and should run on compilers
73 supported by the versions of Ruby we target.
75 === Ragel Compatibility
77 We target the latest released version of Ragel in Debian and will update
78 our code to keep up with new releases. Packaged tarballs and gems
79 include the generated source code so they will remain usable if
80 compatibility is broken.
84 Contributions are welcome in the form of patches, pull requests, code
85 review, testing, documentation, user support or any other feedback is
86 welcome. The mailing list is the central coordination point for all
87 user and developer feedback and bug reports.
89 === Submitting Patches
91 Follow conventions already established in the code and do not exceed 80
94 Inline patches (from "git format-patch -M") to the mailing list are
95 preferred because they allow code review and comments in the reply to
98 We will adhere to mostly the same conventions for patch submissions as
100 {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
102 distributed with git on on patch submission guidelines to follow. Just
103 don't email the git mailing list or maintainer with Unicorn patches :)
107 You can build the Unicorn gem with the following command:
111 == Running Development Versions
113 It is easy to install the contents of your git working directory: