Date | Commit message (Collapse) |
|
They'll continue to be maintained, but we're no longer advertising
them. Also, favor lowercase "unicorn" while we're at it since that
matches the executable and gem name to avoid unnecessary escaping
for RDoc.
|
|
IO#close_on_exec* methods are available since Ruby 1.9.1. It
allows us to use less bytecode as it requires fewer operands and
avoids constant lookups.
|
|
In multithreaded apps, we must use dup2/dup3 with a temporary
descriptor to reopen log files atomically. This is the only way
to protect all concurrent userspace access to a file when reopening.
ref: http://bugs.ruby-lang.org/issues/9036
ref: yahns commit bcb10abe53cfb1d6a8ef7daef59eb10ced397c8a
|
|
If a user specifies a non-regular file for stderr_path or
stdout_path, we should not attempt to reopen or chown
it. This should also allow users to specify FIFOs as log
destinations.
|
|
Users keep both pieces if it's broken :)
|
|
This hopefully makes things easier to read and follow.
|
|
This is slightly shorter and hopefully easier to find.
|
|
A follow-up to 4b23693b9082a84433a9e6c1f358b58420176b27
If multithreaded programming can be compared to juggling
chainsaws, then multithreaded programming with signal handlers
in play is akin to juggling chainsaws on a tightrope
over shark-infested waters.
|
|
IOError may occur due to race conditions as another thread
may close the file immediately after we call File#closed?
to check.
Errno::EBADF may occur in some applications that close a file
descriptor without notifying Ruby (or if two IO objects refer to
the same descriptor, possibly one of them using IO#for_fd).
|
|
While log reopening worked reliably for newly-created File
objects in the unit tests, the $stderr and $stdout handles that
get redirected did not get reopened reliably under Rubinius.
We work around this by relying on Rubinius internals and
directly setting the @path instance variable. This is harmless
for MRI and should be harmless for other any other Ruby
implementations we'll eventually support.
ref: http://github.com/evanphx/rubinius/issues/360
|
|
No point in having namespaces be classes when we never
create instances of them...
|
|
Since we accidentally dropped open_args a while back, nothing
seems to have broken :x So apparently MRI preserves it for us,
and test/unit/test_util.rb agrees.
|
|
Creating File objects while iterating ObjectSpace for File
objects may hit subtle bugs. It may only be safe in MRI, and
even then it's not behavior that sounds sane to rely on. So
stop doing it.
|
|
IO#reopen in Rubinius seems to munge the O_APPEND flag when passed a
path, however passing an actual IO object. However, at the system call
level, everything is the same.
ref: http://github.com/evanphx/rubinius/issues/347
|
|
no point in using "next" here
|
|
This is only supported when SIGUSR1 is sent only to the master
process (which then resends SIGUSR1 to the workers).
Since we only added support for user/group switching in the
workers, we now chown any log files upon switching users so the
master can pick up and chown the log files later on. Thus
we can avoid having to restart workers because they fail to
rotate log files on their own.
|
|
Subclass off the core File class so we don't have to
worry about #size being defined. This will mainly
be useful to Rainbows! but allows us to simplify
our TeeInput implementation a little, too.
|
|
?/ avoids allocating a String in 1.8 and in 1.9 short String
objects are cheap.
|
|
One less thing to RDoc
|
|
This ensures any string literals that pop up in *our* code will
just be a bag of bytes. This shouldn't affect/fix/break
existing apps in most cases, but most constants will always have
the "correct" encoding (none!) to be consistent with HTTP/socket
expectations. Since this comment affects things only on a
per-source basis, it won't affect existing apps with the
exception of strings we pass to the Rack application.
This will eventually allow us to get rid of that Unicorn::Z
constant, too.
|
|
|
|
With the 1.9.2preview1 release (and presumably 1.9.1 p243), the
Ruby core team has decided that bending over backwards to
support crippled operating/file systems was necessary and that
files must be closed before unlinking.
Regardless, this is more efficient than using Tempfile because:
1) no delegation is necessary, this is a real File object
2) no mkdir is necessary for locking, we can trust O_EXCL
to work properly without unnecessary FS activity
3) no finalizer is needed to unlink the file, we unlink
it as soon as possible after creation.
|
|
Ensure we preserve both internal and external encodings
when reopening logs.
|
|
Since I use it myself and also in the tests, we
might as well implement it correctly as a class method
so people can run it in their trap('USR2') hooks.
|