about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2009-02-09More reliable wakeups in master process
This implements the self-pipe trick[1] to wakeup the master process when signaled. We still wakeup every second to reap workers and eventually check for timed out workers. [1] http://cr.yp.to/docs/selfpipe.html
2009-02-09factor out FD_CLOEXEC into SocketHelper module
We'll be using this flag with a pipe, too.
2009-02-09Refactor and get exec + FD inheritance working
Along with worker process management. This is nginx-style inplace upgrading (I don't know of another web server that does this). Basically we can preserve our opened listen sockets across entire executable upgrades. Signals: USR2 - Sending USR2 to the master unicorn process will cause it to exec a new master and keep the original workers running. This is useful to validate that the new code changes took place are valid and don't immediately die. Once the changes are validated (manually), you may send QUIT to the original master process to have it gracefully exit. HUP - Sending this to the master will make it immediately exec a new binary and cause the old workers to gracefully exit. Use this if you're certain the latest changes to Unicorn (and your app) are ready and don't need validating. Unlike nginx, re-execing a new binary will pick up any and all configuration changes. However listener sockets cannot be removed when exec-ing; only added (for now). I apologize for making such a big change in one commit, but once I got the ability to replace the entire codebase while preserving connections, it was too tempting to continue working. So I wrote a large chunk of this while hitting the unicorn-hello-world app with the following loop: while curl -vSsfN http://0:8080; do date +%N; done _Zero_ requests lost across multiple restarts.
2009-02-09HttpResponse: use unbuffered I/O for writing, too
Avoid needless userspace copies and craziness. We'll need to handle EINTR since writes to sockets means stupid things like this, but it's a small cost...
2009-02-09HttpRequest: restart read(2) on EINTR
Since we handle signals, read(2) syscalls can fail on sockets with EINTR. Restart the call if we hit this.
2009-02-09Refactor HTTP Request processing into HttpRequest
Keeping I/O out of unicorn.rb
2009-02-09Skip EINTR/EAGAIN handling with syswrite
I'll be removing signal handling from worker processes...
2009-02-09Use a persistent buffer with HttpRequest
This allows us to avoid the overhead of allocating a new buffer each and every time we call sysread (even when just parsing headers for GET requests).
2009-02-09Use read(2) and blocking I/O for clients
Unicorn is only designed for fast internal networks (and loopback); so avoid wasting time with userspace I/O buffering. This should not significantly affect userspace threading on 1.8 in case your application itself is running threads for some (masochistic) reason as long as the clients you're serving directly with Unicorn are fast.
2009-02-09socket: temporary UNIX sockets use ".#{$$}.tmp"
Instead of ".#{$$}" as the suffix. This makes it clearer that it's a temporary name and also so we can use per-process sockets to make debugging easier.
2009-02-09Remove etc and YAML dependencies
We're not currently using them; and I don't see the need to ever use either...
2009-02-09Remove hard dependency on Rack
While we'll support anything that exposes a Rack-like interface (a very good one IMHO), we shouldn't have a hard dependency on Rack to simplify testing. While we're at it, I'm not using Daemons anymore, either, since that does too many things behind our back as far as daemonization goes. As a result of not depending on Rubygems, either, I've sped up my "make -j" test ~1.5 seconds
2009-02-09HttpRequest#reset! => HttpRequest#reset
Keep this somewhat consistent with the HttpParser API which also exposes #reset instead of #reset!
2009-02-09Get rid of HeaderOut and simplify HttpResponse
Just stuff what little logic we had for it into HttpResponse since Rack takes care of the rest for us. Put the HTTP_STATUS_HEADERS hash in HttpResponse since we're the only user of it. Also, change HttpResponse.send to HttpResponse.write to avoid overriding the default method.
2009-02-09Support multiple listeners per-process
Use select(2) to multiplex non-blocking accept(2) calls between them. Additionally, aggressively make a bet after accepting clients where we'll try to do a non-blocking accept(2) against the full set of descriptors. This is based on the assumption that if we just accepted connections, we're probably reasonably busy. This should lead to lower latency under high load; but some wasted cycles when requests come in intermitently. By this same logic, we don't really care for the thundering herd problem, either; since it is only noticeable with many (hundreds) of processes when most of them are idle.
2009-02-09Internally supporting binding to UNIX domain sockets
Additionally, provide Socket#unicorn_addr which makes it easy to determine whether a given Socket matches one in the config.
2009-02-09Move portability and override Socket stuff to unicorn/socket
We'll be supporting UNIX domain sockets soon... Get rid of tcphack since it was overriding a default method and just manually call Socket.new, bind, listen ourselves. Additionaly, use SO_REUSEADDR when binding since it is convenient for restarts.
2009-02-09Make HttpRequest object (and temp files) persistent
This will help prevent TMPDIR from becoming bloated when handling thousands of large uploads a day. This is a problem in many UNIX filesystems (including ext3): names of entries never expire even after files are gone and the only way to clear it is to get rid of the directory itself.
2009-02-09Don't set SCRIPT_NAME to "/" and then clear it for Rack
It's pointless...
2009-02-09HttpRequest: avoid repeated hash lookups for HTTP_BODY
read_body can be a long-running loop; so avoid wasting CPU cycles by repeatedly performing a hash lookup to get to a temporary buffer.
2009-02-09Simplify HttpResponse since we only handle Rack now
The previous API was very flexible, but I don't think many people really cared for it... We now repeatedly use the same HeaderOut in each process since I completely don't care for multithreading.
2009-02-09HttpResponse: remove send_file
2009-02-09pre-generate HTTP_STATUS_HEADER to avoid repeated snprintf
Regenerating headers constantly is a waste of time.
2009-02-09Remove StringIO usage in HeaderOut
It's more GC-friendly to just use an array than to repeatedly append short strings on top of each other. I also find StringIO confusing...
2009-02-09Disable userspace buffering on client sockets
It's really pointless to allow stdio or something similar to do any sort of buffering on a TCP socket on a Linux box where syscalls are cheap and we have TCP_CORK.
2009-02-09Remove threading and use worker processes instead
All tests for threading and semaphores have been removed. One test was changed because it depended on a shared variable. Tests will be replaced with tests to do process management instead.
2009-02-09s/Mongrel/Unicorn/g
Avoid conflicting with existing Mongrel libraries since we'll be incompatible and break things w/o disrupting Mongrel installations.
2009-02-01Merge branch 'master' of git@github.com:fauna/mongrel v0.0.0
2009-02-01Realistic defaults.
2009-01-31Merge branch 'master' of git@github.com:fauna/mongrel
* 'master' of git@github.com:fauna/mongrel: Clean up some logging.
2009-01-31Fixed lack of QUERY_STRING in env
2009-01-31Clean up some logging.
2009-01-31No more special params hash.
2009-01-31Remove abstract handler.
2009-01-31Remove CGIWrapper.
2009-01-31Made mongrel handle responces the way it should
2009-01-31Mongrel.run(app, opts)
2009-01-31No more throttling.
2009-01-31Make stop raise if server was not started.
2009-01-31Cleanup.
2009-01-31Cleanup.
2009-01-31Cleanup.
2009-01-31Removed bad requires
2009-01-31Merge pivotal code.
Breaks world. Added option to throttle number of concurrent threads processing requests. Conflicts: bin/mongrel_rails lib/mongrel.rb lib/mongrel/configurator.rb lib/mongrel/rails.rb test/unit/test_ws.rb
2009-01-31Moving toward using a logger instead of dumping to STDERR all over the place.
Remove all non-abstract handlers in favor of Rack. Conflicts: lib/mongrel/command.rb lib/mongrel/configurator.rb lib/mongrel/debug.rb lib/mongrel/handlers.rb lib/mongrel/rails.rb test/unit/test_configurator.rb
2009-01-31No commands.
2009-01-31Got rake working took out trash
2009-01-31Merge branch 'rack'
2008-12-04Removed uri_classifier, now we just use racks
2008-12-03Dont need rails adapter anymore, rack handles it