Catch __WARN__ and __DIE__, logging to file.
This commit is contained in:
1 parent
4b7fddd218
commit
5142e4dd97
2 files changed
+28
-3
No files matched your search
@@ -81,9 +81,11 @@ if ($BFVER[0] ne VER.".".SVER.".".REV.RSTAGE."\n") {
|
|||||||
undef @BFVER;
|
undef @BFVER;
|
||||||
|
|
||||||
# Set signal handlers.
|
# Set signal handlers.
|
||||||
$SIG{TERM} = \&signal_TERM;
|
$SIG{TERM} = \&signal_TERM;
|
||||||
$SIG{INT} = \&signal_INT;
|
$SIG{INT} = \&signal_INT;
|
||||||
$SIG{HUP} = \&signal_HUP;
|
$SIG{HUP} = \&signal_HUP;
|
||||||
|
$SIG{'__WARN__'} = \&signal_PerlWARN;
|
||||||
|
$SIG{'__DIE__'} = \&signal_PerlDIE;
|
||||||
API::Std::event_add("on_sigterm");
|
API::Std::event_add("on_sigterm");
|
||||||
API::Std::event_add("on_sigint");
|
API::Std::event_add("on_sigint");
|
||||||
API::Std::event_add("on_sighup");
|
API::Std::event_add("on_sighup");
|
||||||
@@ -423,3 +425,25 @@ sub signal_HUP
|
|||||||
alog "!!! Caught SIGHUP but rehash is unavailable; ignoring";
|
alog "!!! Caught SIGHUP but rehash is unavailable; ignoring";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# __WARN__
|
||||||
|
sub signal_PerlWARN
|
||||||
|
{
|
||||||
|
alog "Perl Warning: ".$_[0];
|
||||||
|
warn $_[0] if $DEBUG;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# __DIE__
|
||||||
|
sub signal_PerlDIE
|
||||||
|
{
|
||||||
|
return if $^S;
|
||||||
|
alog "Perl Fatal: ".$_[0]." -- Terminating program!";
|
||||||
|
API::IRC::quit($_, "A fatal error occurred!") foreach (keys %SOCKET);
|
||||||
|
DB::flush();
|
||||||
|
if (-e "$Bin/auto.pid") {
|
||||||
|
system("rm $Bin/auto.pid");
|
||||||
|
}
|
||||||
|
sleep 1;
|
||||||
|
die "FATAL: ".$_[0];
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Catch __WARN__ and __DIE__, logging to file.
|
||||||
* Added Spanish translations.
|
* Added Spanish translations.
|
||||||
* Added EightBall module.
|
* Added EightBall module.
|
||||||
* Rewrote the socket engine. This should fix random timeouts.
|
* Rewrote the socket engine. This should fix random timeouts.
|
||||||
|
|||||||
Reference in new issue
Block a user