Switched from Auto-Flatfile to SQLite for database backend.
This commit is contained in:
1 parent
a0c58bb471
commit
cd2d91a430
3 files changed
+18
-11
No files matched your search
@@ -14,6 +14,8 @@ use feature qw(switch);
|
||||
use Sys::Hostname;
|
||||
use IO::Socket;
|
||||
use IO::Select;
|
||||
use DBI;
|
||||
use DBD::SQLite;
|
||||
use Class::Unload;
|
||||
use FindBin qw($Bin);
|
||||
our $Bin = $Bin; ## no critic qw(NamingConventions::Capitalization Variables::ProhibitPackageVars)
|
||||
@@ -33,7 +35,7 @@ BEGIN {
|
||||
use Lib::Auto;
|
||||
use API::Std qw(conf_get err);
|
||||
use API::Log qw(println alog dbug);
|
||||
use DB::Flatfile;
|
||||
#use DB::Flatfile;
|
||||
use Parser::Config;
|
||||
use Parser::Lang;
|
||||
use Parser::IRC;
|
||||
@@ -165,8 +167,12 @@ println ' Success';
|
||||
# Expire old logs.
|
||||
API::Log::expire_logs();
|
||||
|
||||
# Load database.
|
||||
DB::load();
|
||||
# Connect to database.
|
||||
if (!-e "$Bin/../etc/auto.db") {
|
||||
system "touch $Bin/../etc/auto.db";
|
||||
system "chmod a+x $Bin/../etc/auto.db";
|
||||
}
|
||||
our $DB = DBI->connect("dbi:SQLite:dbname=$Bin/../etc/auto.db", q{}, q{});
|
||||
|
||||
# Parse privileges.
|
||||
our (%PRIVILEGES);
|
||||
@@ -451,8 +457,8 @@ sub signal_term
|
||||
{
|
||||
API::Std::event_run('on_sigterm');
|
||||
foreach (keys %SOCKET) { API::IRC::quit($_, 'Caught SIGTERM'); }
|
||||
DB::flush();
|
||||
dbug '!!! Caught SIGTERM; terminating...';
|
||||
$DB->disconnect;
|
||||
dbug '!!! Caught SIGTERM; terminating...';
|
||||
alog '!!! Caught SIGTERM; terminating...';
|
||||
if (-e "$Bin/auto.pid") {
|
||||
unlink "$Bin/auto.pid";
|
||||
@@ -466,8 +472,8 @@ sub signal_int
|
||||
{
|
||||
API::Std::event_run('on_sigint');
|
||||
foreach (keys %SOCKET) { API::IRC::quit($_, 'Caught SIGINT'); }
|
||||
DB::flush();
|
||||
dbug '!!! Caught SIGINT; terminating...';
|
||||
$DB->disconnect;
|
||||
dbug '!!! Caught SIGINT; terminating...';
|
||||
alog '!!! Caught SIGINT; terminating...';
|
||||
if (-e "$Bin/auto.pid") {
|
||||
unlink "$Bin/auto.pid";
|
||||
@@ -504,8 +510,8 @@ sub signal_perldie
|
||||
return if $EXCEPTIONS_BEING_CAUGHT;
|
||||
alog 'Perl Fatal: '.$diemsg.' -- Terminating program!';
|
||||
foreach (keys %SOCKET) { API::IRC::quit($_, 'A fatal error occurred!'); }
|
||||
DB::flush();
|
||||
if (-e "$Bin/auto.pid") {
|
||||
$DB->disconnect;
|
||||
if (-e "$Bin/auto.pid") {
|
||||
unlink "$Bin/auto.pid";
|
||||
}
|
||||
sleep 1;
|
||||
|
||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
==================================================================
|
||||
* Switched from Auto-Flatfile to SQLite for database backend.
|
||||
* Added a Badwords module.
|
||||
* Added kick() to API::IRC.
|
||||
* Added DBI and DBD::SQLite to core dependencies.
|
||||
|
||||
+2
-2
@@ -144,7 +144,7 @@ sub cmd_shutdown
|
||||
dbug "Got SHUTDOWN from ".$data{nick}."!".$data{user}."@".$data{host}."/".$data{svr}."! Shutting down. . .";
|
||||
alog "Got SHUTDOWN from ".$data{nick}."!".$data{user}."@".$data{host}."/".$data{svr}."! Shutting down. . .";
|
||||
quit($_, "SHUTDOWN from ".$data{nick}."/".$data{svr}) foreach (keys %Auto::SOCKET);
|
||||
DB::flush();
|
||||
$Auto::DB->disconnect;
|
||||
system("rm $Auto::Bin/auto.pid");
|
||||
exit;
|
||||
|
||||
@@ -166,7 +166,7 @@ sub cmd_restart
|
||||
dbug "Got RESTART from ".$data{nick}."!".$data{user}."@".$data{host}."/".$data{svr}."! Restarting. . .";
|
||||
alog "Got RESTART from ".$data{nick}."!".$data{user}."@".$data{host}."/".$data{svr}."! Restarting. . .";
|
||||
quit($_, "RESTART from ".$data{nick}."/".$data{svr}) foreach (keys %Auto::SOCKET);
|
||||
DB::flush();
|
||||
$Auto::DB->disconnect;
|
||||
system("rm $Auto::Bin/auto.pid") if -e "$Auto::Bin/auto.pid";
|
||||
|
||||
# Time to come back from the dead!
|
||||
|
||||
Reference in new issue
Block a user