[OSM-dev] Idle/re-exec patch.
Robert Hart
bathterror at gmail.com
Tue Apr 3 21:53:48 BST 2007
Framm,
The re-exec feature works on windows under cygwin, not sure about other perl
clients.
I also attach a patch that slightly modifies the output for the new idle
reporting feature, so that it now shows how long since the last tile was
rendered, instead of counting down until the next request will be.
Rob
--
--
Robert Hart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070403/6f9305aa/attachment.html>
-------------- next part --------------
Index: tilesGen.pl
===================================================================
--- tilesGen.pl (revision 2381)
+++ tilesGen.pl (working copy)
@@ -38,8 +38,8 @@
# Get version number from version-control system, as integer
my $Version = '$Revision$';
$Version =~ s/\$Revision:\s*(\d+)\s*\$/$1/;
-printf STDERR "This is version %d (%s) of tilesgen\n",
- $Version, $Config{ClientVersion};
+printf STDERR "This is version %d (%s) of tilesgen running on %s\n",
+ $Version, $Config{ClientVersion}, $^O;
unless ($Config{Verbose})
{
@@ -88,6 +88,7 @@
my $lastmsglen = 0;
my $progstart = time();
my $idleSeconds = 0;
+my $idleFor = 0;
my $dirent;
# Handle the command-line
@@ -133,13 +134,10 @@
uploadIfEnoughTiles();
if ($did_something == 0)
{
- my $totalseconds = time() - $progstart;
- $message = sprintf("Client %d%% idle. %s",
- $totalseconds ? $idleSeconds * 100 / $totalseconds : 100,
- $message);
talkInSleep($message, 60);
- $idleSeconds += 60;
- }
+ } else {
+ $idleFor = 0;
+ }
}
}
elsif ($Mode eq "upload") {
@@ -1040,8 +1038,15 @@
for (my $i = 0; $i< $duration; $i++)
{
- statusMessage(sprintf("%s, sleeping (%d)", $message, $duration - $i));
+ my $totalseconds = time() - $progstart;
+
+ statusMessage(sprintf("%s. Idle for %d:%02d (%d%% idle) ",
+ $message,
+ $idleFor/60, $idleFor%60,
+ $totalseconds ? $idleSeconds * 100 / $totalseconds : 100));
sleep 1;
+ $idleFor++;
+ $idleSeconds++;
}
}
@@ -1057,7 +1062,7 @@
{
# until proven to work with other systems, only attempt a re-exec
# on linux.
- return unless ($^O eq "linux");
+ return unless ($^O eq "linux" || $^O eq "cygwin");
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
$ctime,$blksize,$blocks) = stat($0);
More information about the dev
mailing list