Comments (10)
Would like to know this too. Need a signal number to send, or some run flag, or something else. And this function (log file reopen) should not delay requests processing and i suppose should not force starman to reread psgi app.
from starman.
Just since you guys were asking "how" - the answer is that it's not supported as of currently.
from starman.
Thanks Tatsuhiko! "Not supported" is enough for "how to".
from starman.
I'm looking at implementing a workaround to do this using the pluggable logging facility of Starman::Server's base class Net::Server in combination with Log::Log4perl's ability to re-open log files via the Log::Log4perl::Appender::File recreate_check_signal option. However, this requires passing command line parameters that Net::Server can access and Starman::Server->run doesn't pass them on. (starman passes unknown parameters to Plack::Runner and they get stored as key value pairs in $self->{options} but they don't make it to Net::Server which expects them in $self->{server}.)
I put a rather broad hack in that works for me but my setup doesn't really exercise all of the command line parameters so I'm not sure if the hack breaks anything else. I tried to run it against the test suite using "cpanm --look starman" but I don't know my way around the build dir structure well enough to get anything done and there weren't any instructions.
Here is the diff if you're interested:
*** lib/Starman/Server.pm 2013-04-06 22:04:57.000000000 -0700
--- lib/Starman/Server.new.pm 2013-04-17 11:14:23.121528622 -0700
***************
*** 66,69 ****
--- 67,74 ----
$self->SUPER::run(
+ # Pass all raw command line options to our parent Which expects them
+ # here. Any that need to be modified by our option parsing get
+ # clobbered below
+ %$options,
port => $port,
host => $host,
from starman.
Could we not simply change the logging so it closes/reopens the filehandle on every write? This file doesn't usually get written to that often, so it wouldn't be inefficient.
from starman.
@karenetheridge that would be one approach to adding this functionality. So would just re-opening the handle on HUP. But, Net::Server doesn't offer an API for directly affecting the filehandle. The filehandle itself appears to be intended as private so I am hesitant to add code that depends upon it's implementation. One alternative would be to override the methods that access the filehandle, however those are big methods and it seemed like that couldn't be done easily without a lot of copy pasta. Another alternative would be to submit a patch to Net::Server that exposed the filehandle for fiddling.
I opted for the code I shared above because it's changes far fewer lines of code, uses the parent's exposed API and adds exposure to other parts of the parent's API. The downside is that the pluggable logging does require more configuration up-front.
from starman.
@benrifkah I know you want to use Log4perl et al, but just as a FYI, we use this setup at $work:
use strict;
use Plack::Builder;
use File::RotateLogs;
my $roratelogs = File::RotateLogs->new(
logfile => "/path/to/logfile.%Y%m%d%H",
linkname => "/path/to/logfile", # symlink pointing to newest one
rotationtime => 7200, # when to rotate logs (short, because we get a LOT of hits)
maxage => 86400 * 14, # when to purge old olgs
);
builder {
enable 'AccessLog', logger => sub { $rotatelogs->print(@_) };
$app;
};
from starman.
@lestrrat that is a great way to ensure that the ACCESS log gets rotated. It is similar to what we're doing with Log4perl. However, I think you'll find that it doesn't work for the ERROR log which is what this thread is about. Since the error log filehandle is owned by Net::Server which isn't aware of Plack::Builder it would take breaking some API boundaries to make it configurable via middleware.
from starman.
@benrifkah Oh I see. My bad. Again, just FYI we don't worry about doing error log locations because we just print it to STDERR and let daemontools' multilog handle the log management.
from starman.
Actually, is this even needed? You can create a "Net::Server::Log::MyClass" class that handles the logging, and then for the error-log parameter pass "MyClass". It works.
from starman.
Related Issues (20)
- tests fail -- empty base class package HOT 1
- Starman in Production HOT 2
- Implement --max-keepalive-requests HOT 3
- POSIX::setgid not implemented on this architecture HOT 1
- starman hangs on make tests (Win 7, Strawberry perl) HOT 1
- Starman is missing ExtUtils::Config requirement HOT 1
- Support custom proctitles
- Dependency module name misspelling
- plackup: Use of uninitialized value $opt in lc at /home/vagrant/perl5/lib/perl5/Starman/Server.pm line 80.
- Feature request: Ability to run Starman in non-forking mode HOT 1
- How to use with systemd ExecReload and ExecStop? HOT 1
- start_server ignores https/ssl configuration of starman/plackup HOT 1
- allow client errors to be detected HOT 2
- Support for server-side trailer headers with chunk-encoded responses
- on some hosts requests are too slow - any ideas ? HOT 1
- *
- Please add config option to `chmod` a UNIX socket
- --listen and --host options do not support IPv6 addresses HOT 4
- Add worker timeout option HOT 3
- Starman worker zombie processes showing up HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starman.