I have a forking server. I load all modules before I fork.
...or do I? I want a message to be logged to STDERR for every module loaded after a certain point in my program.
I was going to use the following, but it's logging some scripts executed using do
.
my %ignore = map { $_ => 1 } ( ... );
unshift @INC, sub {
my (undef, $path) = @_;
warn("$path wasn't loaded before forking.\n")
if !$ignore{$path};
return ();
};
I'm not out of ideas, but before I spend more time on this, I was wondering if there's an existing solution.
What things are using do
? Is simply
if $path =~ /\.pm\z/ && !$ignore{$path};
good enough to distinguish?
Other options:
Static code analysis with PPI (using or based on Module::Extract::Use).
Dump %INC to a file upon SIGHUP or some other signal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With