about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2009-05-26unicorn 0.8.0 v0.8.0
2009-05-25Switch to autoload to defer requires
This should prevent Rack from being required too early on so "-I" being passed through the unicorn command-line can modify $LOAD_PATH for Rack
2009-05-25Only refresh the gem list when building the app
No point in refreshing the list of gems unless the app can actually be reloaded.
2009-05-25Refresh Gem list when building the app
On application reloads, Gems installed by the Ruby instance may be different than when Unicorn started. So when preload_app is false, HUP-ing Unicorn will always refresh the list of Gems before loading the application code.
2009-05-22Merge commit 'v0.7.1'
* commit 'v0.7.1': unicorn 0.7.1 Conflicts: lib/unicorn/const.rb
2009-05-22unicorn 0.7.1 v0.7.1
2009-05-22http_response: allow string status codes
Rack::Lint says they just have to work when to_i is called on the status, so that's what we'll do.
2009-05-22Enforce minimum timeout at 3 seconds
2 seconds is still prone to race conditions under high load. We're intentionally less accurate than we could be in order to reduce syscall and method dispatch overhead.
2009-05-22configurator: fix rdoc formatting
2009-05-22Preserve 1.9 IO encodings in reopen_logs
Ensure we preserve both internal and external encodings when reopening logs.
2009-05-22Fix a warning about @pid being uninitialized
2009-05-22Ignore unhandled master signals in the workers
This makes it easier to use "killall -$SIGNAL unicorn" without having to lookup the correct PID.
2009-05-22Safer timeout handling and test case
Timeouts of less than 2 seconds are unsafe due to the lack of subsecond resolution in most POSIX filesystems. This is the trade-off for using a low-complexity solution for timeouts. Since this type of timeout is a last resort; 2 seconds is not entirely unreasonable IMNSHO. Additionally, timing out too aggressively can put us in a fork loop and slow down the system. Of course, the default is 60 seconds and most people do not bother to change it.
2009-05-22app/old_rails: correctly log errors in output
"out" was an invalid variable in that context...
2009-05-22app/exec_cgi: GC prevention
Don't allow newly created IO objects to get GC'ed and subsequently close(2)-ed. We're not reopening the {$std,STD}{in,out,err} variables since those can't be trusted to have fileno 1, 2 and 3 respectively.
2009-05-13privatize constants only used by old_rails/static
Unicorn proper no longer needs these constants, so don't bother with them.
2009-05-13http_response: allow string status codes
Rack::Lint says they just have to work when to_i is called on the status, so that's what we'll do.
2009-05-13Require Rack for HTTP Status codes
Preventing needless duplication since Rack already has these codes for us. Also, put the status codes in HttpResponse since nothing else needs (or should need) them.
2009-05-12Reopen master logs on SIGHUP, too
There may be other logs opened if preload_app is true besides stderr/stdout paths. So err on the safe side and reopen everything.
2009-05-11exec_cgi: don't assume the body#each consumer is a socket
If we're using middleware that pushes the body into an array, bad things will happen if we're clobbering the string for each iteration of body#each.
2009-05-11HttpRequest::DEF_PARAMS => HttpRequest::DEFAULTS
Give this a more palatable name and unfreeze it, allowing users to modify it more easily.
2009-05-10Avoid killing sleeping workers
This used to happen on machines that were coming out of suspend/hibernation.
2009-05-10Enforce minimum timeout at 3 seconds
2 seconds is still prone to race conditions under high load. We're intentionally less accurate than we could be in order to reduce syscall and method dispatch overhead.
2009-05-10app/exec_cgi: use explicit buffers for read/sysread
This reduces garbage generation to improve performance. Rack 1.0 allows InputWrapper to read with an explicit buffer.
2009-05-10http_request: use Rack::InputWrapper-compatible methods
This allows alternative I/O implementations to be easier to use with Unicorn...
2009-05-10configurator: fix rdoc formatting
2009-05-04Preserve 1.9 IO encodings in reopen_logs
Ensure we preserve both internal and external encodings when reopening logs.
2009-05-04Inline and remove the HttpRequest#reset method
These potentially leaves an open file handle around until the next request hits the process, but this makes the common case faster.
2009-05-04Fix a warning about @pid being uninitialized
2009-05-03Speed up the worker accept loop
First, reduce no-op fchmod syscalls under heavy traffic. gettimeofday(2) is a cheaper syscall than fchmod(2). Since ctime resolution is only in seconds on most filesystems (and Ruby can only get to seconds AFAIK), we can avoid fchmod(2) happening within the same second. This allows us to cheat on synthetic benchmarks where performance is measured in requests-per-second and not seconds-per-request :) Secondly, cleanup the acceptor loop and avoid nested begins/loops as much as possible. If we got ECONNABORTED, then there's no way the client variable would've been set correctly, either. If there was something there, then it is at the mercy of the garbage collector because a method can't both return a value and raise an exception.
2009-05-03Instant shutdown signals really mean instant shutdown
Use SIGQUIT if you're going to be nice and do graceful shutdowns. Sometimes people run real applications on this server and SIGINT/SIGTERM get lost/trapped when Object is rescued and that is not good. Also make sure we break out of the loop properly when the master is dead. Testcases added for both SIGINT and dead master handling.
2009-05-04Remove redundant socket closing/checking
If our response succeeds, we've already closed the socket. Otherwise, we would've raised an exception at some point hit one of the rescue clauses.
2009-05-03Ignore unhandled master signals in the workers
This makes it easier to use "killall -$SIGNAL unicorn" without having to lookup the correct PID.
2009-05-03Safer timeout handling and test case
Timeouts of less than 2 seconds are unsafe due to the lack of subsecond resolution in most POSIX filesystems. This is the trade-off for using a low-complexity solution for timeouts. Since this type of timeout is a last resort; 2 seconds is not entirely unreasonable IMNSHO. Additionally, timing out too aggressively can put us in a fork loop and slow down the system. Of course, the default is 60 seconds and most people do not bother to change it.
2009-05-03No point in unsetting the O_NONBLOCK flag
Since we've switched to readpartial, we'll already be protected from any unpleasant errors that might get thrown at us. There's no easy way to prevent MRI from calling a select() internally to check for readiness, so speculative+blocking read() calls are out already. Additionally, most requests come in the form of GETs which are fully-buffered in the kernel before we even accept() the socket; so a single readpartial call will be enough to fully consume it.
2009-05-03http_request: switch to readpartial over sysread
readpartial is actually as low-level as sysread is, except it's less likely to throw exceptions and won't change the blocking/non-blocking status of a file descriptor (we explicitly enable blocking I/O)
2009-05-03http_response: luserspace buffering is barely faster
Simpler code on our end can be just a tick faster because syscalls are still not as cheap as normal functions and this still manages to play well with our lack of keepalive support as closing the socket will flush it immediately.
2009-05-03http_request: avoid StringIO.new for GET/HEAD requests
Since the vast majority of web traffic is GET/HEAD requests without bodies, avoid creating a StringIO object for every single request that comes in.
2009-05-03app/old_rails: correctly log errors in output
"out" was an invalid variable in that context...
2009-05-02Make speculative accept() faster for the common case
Only do speculative accept on the previous ready set of listeners. This makes it less CPU-intensive to have per-process debug listeners configured. Unfortunately, this makes non-primary listeners unable to accept connections if the server is under extremely heavy load and speculative accept() on the previous listener is always succeeding and hogging the process. Fortunately, this is an uncommon case.
2009-05-02app/exec_cgi: GC prevention
Don't allow newly created IO objects to get GC'ed and subsequently close(2)-ed. We're not reopening the {$std,STD}{in,out,err} variables since those can't be trusted to have fileno 1, 2 and 3 respectively.
2009-04-26Small cleanup
No need to use ensure since process_client will handle errors regardless. And if not, there's a bug on our side that needs to fixed.
2009-04-25unicorn 0.7.0 v0.7.0
2009-04-25Rack 1.0.0 compatibility
Keep in mind that it's plenty possible to use Unicorn as a library without using Rack itself. Most of the unit tests do not depend on Rack, for example.
2009-04-25Fix log rotation being delayed in workers when idle
We were closing a no-longer-existent I/O object to break out of IO.select. This was broken in 0.6.0 but did not affect the worker when it was busy.
2009-04-24configurator: "listen" directive more nginx-like
The following specifications to bind port 8080 on all interfaces are now accepted in the configuration file: listen "8080" # (with quotes) listen 8080 # (without quotes)
2009-04-24unicorn 0.6.0 v0.6.0
2009-04-24cleanup: avoid duped self-pipe init/replacement logic
We do this in both the worker and master processes, so avoid repeating ourselves.
2009-04-24SIGTT{IN,OU} {in,de}crements worker_processes
This allows dynamic tuning of the worker_processes count without having to restart existing ones. This also allows worker_processes to be set to a low initial amount in the config file for low-traffic deployments/upgrades and then scaled up as the old processes are killed off. Remove the proposed reexec_worker_processes from TODO since this is far more flexible and powerful. This will allow not-yet-existent third-party monitoring tools to dynamically change and scale worker processes according to site load without increasing the complexity of Unicorn itself.
2009-04-24Allow std{err,out}_path to be changed via HUP
Seems like a good idea to be able to relocate log files on a config reload.