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