summaryrefslogtreecommitdiff
path: root/util/multi.pl
diff options
context:
space:
mode:
authoryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-04-27 06:41:52 +0000
committeryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-04-27 06:41:52 +0000
commit04c26425699a3e01d0e2abe52ad9f763396cd940 (patch)
tree4923a840ac27da9bc9bc322dec51d0504834dfe5 /util/multi.pl
parenta9e444bb39f5c356b66ef247b4539937daa25503 (diff)
Made Multis queue persistent in shared memory
git-svn-id: svn://vndb.org/vndb@8 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
Diffstat (limited to 'util/multi.pl')
-rw-r--r--util/multi.pl21
1 files changed, 7 insertions, 14 deletions
diff --git a/util/multi.pl b/util/multi.pl
index 4c22bced..022160ee 100644
--- a/util/multi.pl
+++ b/util/multi.pl
@@ -34,10 +34,9 @@ package Multi;
use strict;
use warnings;
+use Tie::ShareLite ':lock';
use Time::HiRes;
use POE;
-use Storable 'freeze', 'thaw';
-use IPC::ShareLite ':lock';
use DBI;
use lib '/www/vndb/lib';
@@ -52,20 +51,18 @@ BEGIN { require 'global.pl' }
$ENV{PATH} = '/usr/bin';
-our $VERSION = '0.9';
our $LOGDIR = '/www/vndb/data/log';
our $LOGLVL = 3; # 3:DEBUG, 2:ACTIONS, 1:WARN
-our $RESTART = 0;
+our $STOP = 0;
our $DAEMONIZE = (grep /^-c$/, @ARGV) ? 1 : (grep /^-s$/, @ARGV) ? 2 : 0;
our %MODULES = ();
if(grep /^-a$/, @ARGV) {
- my $s = IPC::ShareLite->new(-key => $VNDB::SHMKEY,-create => 1, -destroy => 0);
+ my $s = tie my %s, 'Tie::ShareLite', @VNDB::SHMOPTS;
$s->lock(LOCK_EX);
- my $l = $s->fetch();
- my @queue = ($l?@{thaw($l)}:(), grep !/^-/, @ARGV);
- $s->store(freeze(\@queue));
+ my @q = ( ($s{queue} ? @{$s{queue}} : ()), (grep !/^-/, @ARGV) );
+ $s{queue} = \@q;
$s->unlock();
exit;
}
@@ -81,17 +78,13 @@ Multi::RG->spawn();
Multi::Image->spawn();
Multi::Sitemap->spawn();
Multi::Maintenance->spawn();
-Multi::IRC->spawn(
- server => 'irc.synirc.net',
- user => 'Multi_'.$$,
- channel => '#vndb_test'
-) if 0;
+Multi::IRC->spawn() if !$VNDB::DEBUG;
$SIG{__WARN__} = sub {(local$_=shift)=~s/\r?\n//;$poe_kernel->call(core=>log=>1,'__WARN__: '.$_)};
$poe_kernel->run();
-exec $0, grep /^-/, @ARGV if $RESTART;
+exec $0, grep /^-/, @ARGV if $STOP == 2;