Telephone +44(0)1524 64544
Email: info@shadowcat.co.uk

opw-2012 - mxd

Sat Dec 22 00:30:00 2012

Slides for the talk mxd at opw-2012

-

Bug
hunt

-

Ok.

-

"My logging
doesn't work
anymore"

-

(Catalyst
application)

-

Upgraded
to 5.90

-

What
happened?

-

We switched
to Plack

-

Um ...

-

WHYYYYYY

-

"Actually
... it's
logging to
my pid file"

-

?!?!?!

-

"and it only
happens in
production"

-

... wait

-

myapp_fastcgi.pl

-

MooseX::Daemonize

-

fork
setsid
fork

-

fork
setsid
close fds
fork

-

Wait.

-

close fds?

-

  my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX );
  POSIX::close($_) foreach (0 .. $openmax);

-

POSIX::close?

-

... oh my.

-

PerlIO
refcounts
fdnos

-

So an existing
filehandle to
that fdno makes
close() a no-op

-

... oh my.

-

Server
starts

-

Server
opens
log file

-

Server
daemonizes

-

All filehandles
are closed

-

Pid file
opened

-

*re-uses*
last fdno

-

... which is
the one for
THE LOG FILE

-

Pid file
closed

-

... PerlIO
ignores it.

-

... app
logs to
pidfile

-

Solution?

-

Always set
dont_close_all_fds

-

Or don't open
your log files
until after
daemonize ...

-

Bloody
software.

-

Thank You
IRC:mst
mst@shadowcat.co.uk
@shadowcat_mst