Where can I find application runtime errors using Nginx, Starman, Plack and Catalyst?
I have managed successfully to server my Catalyst app on my development machine using Plack + Starman, using a daemon script I based on one I 开发者_JAVA技巧found in Dave Rolsky's Silki distribution.
I then set up nginx to reverse proxy to my Starman server, and aliased the static directory for nginx to serve. So far, so good. However, I am at a loss as to where my application STDERR is supposed to be logging to. It isn't reaching nginx (I suppose that makes sense) but I can't find much documentation as to where Starman may be logging it - if anywhere. I did have a look at Plack's Middleware modules but only saw options for access logs.
Can someone help me?
It's going nowhere. Catalyst::Log
is sending data to STDERR
, and the init script is sending STDERR
to /dev/null
.
You have a few basic choices:
Replace
Catalyst::Log
with something like Catalyst::Log::Log4perl or simply a subclass ofCatalyst::Log
with overridden_send_to_log
-- either one will allow you to send the logging output somewhere other than STDERR.Write some code that runs at the PSGI level to manage a logfile and reopen STDERR to it. I tried this, it wasn't very pleasant. Logfiles are harder than they look.
Use FastCGI instead, and you'll have an error stream that sends the log output back to the webserver. You can still use Plack via Plack::Handler::FCGI / Plack::Handler::FCGI::Engine (I'd recommend the latter, because the FCGI::Engine code is much newer and nicer than FCGI.pm).
I realise it is a long time since the question was asked, but I've just hit the same problem...
You actually have one more option than Hobbs mentioned.
It isn't quite the "init script" that is sending STDERR to /dev/null, it is Starman.
If you look at the source code for Starman, you would discover that, if you give it the --background
flag, it uses MooseX::Daemonize::Core
.
And once you know that, its documentation will tell you that it deliberately closes STDERR, STDOUT and STDIN and re-directs them to /dev/null, AND that it takes the environment variables MX_DAEMON_STDERR and MX_DAEMON_STDOUT as names of files to use instead.
So if you start your catalyst server with MX_DAEMON_STDERR set to a file name, STDERR will go to that file.
Today Starman has a --error-log
command line option which allows you to redirect error messages to a file.
See documentation of starman
:
--error-log
Specify the pathname of a file where the error log should be written. This enables you to still have access to the errors when using
--daemonize
.
精彩评论