Mercurial > eagle-eye
diff scan.pl @ 238:1a7b2d42fcbf
fixed the stupid timeout and cache timing
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 07 Nov 2008 11:30:11 +0800 |
parents | 978a949602e5 |
children | 38e1a82627a9 |
line wrap: on
line diff
--- a/scan.pl Thu Nov 06 22:03:07 2008 +0800 +++ b/scan.pl Fri Nov 07 11:30:11 2008 +0800 @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; use Data::Dumper; +use Carp; use Ikariam; package main; @@ -15,6 +16,7 @@ } foreach my $h_city (@cities) { + Carp::carp(sprintf("checking %s\n", $h_city->{'cityname'})); $h_city->{island} = $island; $h_city->{'time'} = time; my $c = Ikariam::Cities->retrieve($h_city->{cityId}); @@ -28,7 +30,7 @@ $c->update(); my $user = Ikariam::User->retrieve($h_city->{'user'}); - next if (defined($user) && defined($user->time) && $user->time le (time - 30*60*1)); + next if (defined($user) && defined($user->time) && $user->time gt (time - 30*60)); saveUser($h_city->{owner}); } @@ -43,7 +45,7 @@ $users = $::i->viewScore($x, $userName, 0); foreach my $h_user (values(%{$users})) { - printf("Saving user %s\n", $h_user->{'name'}); + Carp::croak(sprintf("Saving user %s\n", $h_user->{'name'})); $h_user->{'time'} = time; my $user = Ikariam::User->retrieve($h_user->{'id'}); @@ -93,7 +95,8 @@ } # scanning the island - if($island->time le (time - 30*60*6)) + # 10 minutes cache. + if($island->time le (time - 60*10)) { my @cities = $::i->viewIsland($h_island->{id}); saveCities($h_island->{id}, @cities); @@ -106,8 +109,8 @@ } -local $SIG{ALRM} = sub { die "timeout\n" }; -alarm 3; +# local $SIG{ALRM} = sub { die "timeout\n" }; +# alarm 3; our $i = new Ikariam($::server, $::user, $::pass); if($#ARGV == 1) {