From b52c7c95096825846f53e73de627e6cda01d9bca Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 1 Nov 2008 18:42:11 +0100 Subject: [PATCH] Use FindBin and send USR1 to irssi --- lib/NDWeb/Controller/Members.pm | 1 + scripts/fetchdumps.pl | 13 ++++++++----- scripts/ndrank.pl | 4 +++- scripts/parsealliances.pl | 3 ++- scripts/parsegalaxies.pl | 3 ++- scripts/parseplanets.pl | 3 ++- scripts/reset_hosts.pl | 5 ++++- scripts/scans.pl | 5 +++++ scripts/stats.pl | 5 ++++- scripts/tick.pl | 5 ++++- 10 files changed, 35 insertions(+), 12 deletions(-) diff --git a/lib/NDWeb/Controller/Members.pm b/lib/NDWeb/Controller/Members.pm index 4e57477..6dcc1f6 100644 --- a/lib/NDWeb/Controller/Members.pm +++ b/lib/NDWeb/Controller/Members.pm @@ -265,6 +265,7 @@ sub postircrequest : Local { (uid,channel,message) VALUES($1,$2,$3) }); $query->execute($c->user->id,$c->req->param('channel'),$c->req->param('message')); + system 'killall','-USR1', 'irssi'; $c->flash(reply => "Msg sent to: ".$c->req->param('channel')); $c->res->redirect($c->uri_for('ircrequest')); diff --git a/scripts/fetchdumps.pl b/scripts/fetchdumps.pl index 2579f38..1bb0736 100755 --- a/scripts/fetchdumps.pl +++ b/scripts/fetchdumps.pl @@ -27,7 +27,9 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; + use ND::DB; our $dbh = ND::DB::DB(); @@ -51,11 +53,12 @@ for my $type ("planet","alliance","galaxy"){ } if ($updated){ - `/var/www/ndawn/scripts/parsealliances.pl $updated`; - `/var/www/ndawn/scripts/parseplanets.pl $updated`; - `/var/www/ndawn/scripts/parsegalaxies.pl $updated`; - `/var/www/ndawn/scripts/ndrank.pl`; + `perl $FindBin::Bin/parsealliances.pl $updated`; + `perl $FindBin::Bin/parseplanets.pl $updated`; + `perl $FindBin::Bin/parsegalaxies.pl $updated`; + `perl $FindBin::Bin/ndrank.pl`; $dbh->do(q{UPDATE misc SET value = ? WHERE id = 'TICK'}, undef, $updated); + system 'killall','-USR1', 'irssi'; local $dbh->{Warn} = 0; $dbh->do(q{VACUUM ANALYZE}); } diff --git a/scripts/ndrank.pl b/scripts/ndrank.pl index e5d152c..acb1405 100755 --- a/scripts/ndrank.pl +++ b/scripts/ndrank.pl @@ -27,7 +27,9 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; + use ND::DB; our $dbh = ND::DB::DB(); diff --git a/scripts/parsealliances.pl b/scripts/parsealliances.pl index f8daeaf..bc43e96 100755 --- a/scripts/parsealliances.pl +++ b/scripts/parsealliances.pl @@ -27,7 +27,8 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; use ND::Include; use ND::DB; diff --git a/scripts/parsegalaxies.pl b/scripts/parsegalaxies.pl index af9d6ec..95194be 100755 --- a/scripts/parsegalaxies.pl +++ b/scripts/parsegalaxies.pl @@ -27,7 +27,8 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; use ND::Include; use ND::DB; diff --git a/scripts/parseplanets.pl b/scripts/parseplanets.pl index e3c013a..fa31c1e 100755 --- a/scripts/parseplanets.pl +++ b/scripts/parseplanets.pl @@ -27,7 +27,8 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; use ND::Include; use ND::DB; diff --git a/scripts/reset_hosts.pl b/scripts/reset_hosts.pl index 20f0102..040445b 100755 --- a/scripts/reset_hosts.pl +++ b/scripts/reset_hosts.pl @@ -6,7 +6,10 @@ use DBI; use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + use ND::DB; our $dbh = ND::DB::DB(); diff --git a/scripts/scans.pl b/scripts/scans.pl index 818be59..182fe08 100755 --- a/scripts/scans.pl +++ b/scripts/scans.pl @@ -91,6 +91,8 @@ $dbh->begin_work or die 'No transaction'; $newscans->execute or die $dbh->errstr; $dbh->pg_savepoint('scans') or die "No savepoint"; +my $parsedscans = 0; + while (my $scan = $newscans->fetchrow_hashref){ $dbh->pg_release('scans') or die "Couldn't save"; $dbh->pg_savepoint('scans') or die "Couldn't save"; @@ -206,6 +208,7 @@ while (my $scan = $newscans->fetchrow_hashref){ } $parsedscan->execute($tick,$type,$planet,$scan->{id}) or die $dbh->errstr; #$dbh->rollback; + ++$parsedscans; }; if ($@) { warn $@; @@ -220,6 +223,8 @@ while (my $scan = $newscans->fetchrow_hashref){ #$dbh->rollback; $dbh->commit; +system 'killall','-USR1', 'irssi' if $parsedscans; + sub addfleet { my ($name,$mission,$ships,$sender,$target,$tick,$eta,$back,$amount,$ingal) = @_; diff --git a/scripts/stats.pl b/scripts/stats.pl index f5e11ec..706d7c7 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -26,7 +26,10 @@ use DBI; use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + use ND::DB; our $dbh = ND::DB::DB(); diff --git a/scripts/tick.pl b/scripts/tick.pl index 5f8b862..232dfc6 100755 --- a/scripts/tick.pl +++ b/scripts/tick.pl @@ -7,11 +7,14 @@ use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/lib/}; +use FindBin; +use lib "$FindBin::Bin/../lib"; + use ND::DB; our $dbh = ND::DB::DB(); my $update = $dbh->prepare("UPDATE misc SET value = value::int + 1 WHERE id = 'TICK'"); $update->execute(); +system 'killall','-USR1', 'irssi'; $dbh->disconnect; -- 2.39.2