From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-mirrorstats:master commit in: /
Date: Wed, 22 Mar 2023 16:29:41 +0000 (UTC) [thread overview]
Message-ID: <1679502574.a8e55ea71ba5602d791561c105310a53566f0503.robbat2@gentoo> (raw)
commit: a8e55ea71ba5602d791561c105310a53566f0503
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 22 16:29:34 2023 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Wed Mar 22 16:29:34 2023 +0000
URL: https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=a8e55ea7
probe-mirmon: cleanup
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
probe-mirmon | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/probe-mirmon b/probe-mirmon
index a40be16..233b6a3 100755
--- a/probe-mirmon
+++ b/probe-mirmon
@@ -76,7 +76,15 @@ sub handle_wget {
my ( $timeout, $url ) = @_;
# TODO: replace this with native HTTP
# TODO: munge the output!
- exec {'/usr/bin/wget'} 'wget', qw( -q --passive-ftp -O - -T ), $timeout, '-t', 1, $url;
+ # kill -9 wget when it gets really stuck.
+ my $tmpdir = File::Tempdir->new();
+ my $dir = $tmpdir->name;
+ my $file = $url;
+
+ $file =~ s/\W/_/g; # translate all non-letters to _
+ system {'/usr/bin/timeout'} qw(--preserve-status -s KILL -k ), ($timeout + 1), ($timeout + 0.5),
+ 'wget', qw( -q --passive-ftp -T ), $timeout, '-t', 1, '-O', "$dir/$file", $url;
+ slurp_and_output("$dir/$file");
}
sub handle_rsync {
@@ -90,20 +98,18 @@ sub handle_rsync {
# https://stackoverflow.com/a/6331618/1583179
my ($stdout, $stderr, $ret) = capture {
- system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file";
+ system {'/usr/bin/rsync'} qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file";
};
+ #print "STDOUT: $stdout\n";
+ #print "STDERR $stderr\n";
+ #print "RET: $ret\n";
if ($ret!=0) {
#warn "rsync failed, exit code $fail, $! $? $@\n";
#exit $ret;
exit 800;
}
- open my $fh, '<', "$dir/$file" or do {
- warn "Opening Downloaded timestamp Failed";
- exit 900; # rediculous exit code.
- };
-
- print munge_date(<$fh>);
+ slurp_and_output("$dir/$file");
exit 0;
}
@@ -123,3 +129,16 @@ sub munge_date {
}
return -1;
}
+
+sub slurp_and_output {
+ my $filename = shift;
+ open my $fh, '<', $filename or do {
+ warn "Opening Downloaded timestamp Failed";
+ exit 900; # rediculous exit code.
+ };
+ my $line = <$fh>;
+ #print "RAW: $line\n";
+
+ print munge_date($line), "\n";
+ exit 0;
+}
next reply other threads:[~2023-03-22 16:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 16:29 Robin H. Johnson [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-03-22 17:44 [gentoo-commits] proj/gentoo-mirrorstats:master commit in: / Robin H. Johnson
2023-03-22 16:29 Robin H. Johnson
2020-05-01 17:59 Robin H. Johnson
2020-04-30 22:59 Robin H. Johnson
2020-04-30 22:56 Robin H. Johnson
2020-04-30 22:56 Robin H. Johnson
2020-04-30 22:52 Robin H. Johnson
2020-04-30 22:17 Robin H. Johnson
2020-04-30 21:27 Robin H. Johnson
2020-04-30 21:27 Robin H. Johnson
2020-04-30 21:11 Robin H. Johnson
2020-04-30 20:29 Robin H. Johnson
2020-04-30 6:31 Robin H. Johnson
2020-04-30 6:02 Robin H. Johnson
2020-04-29 6:45 Robin H. Johnson
2020-04-29 6:39 Robin H. Johnson
2020-04-29 5:48 Robin H. Johnson
2020-04-29 5:41 Robin H. Johnson
2020-04-29 5:33 Robin H. Johnson
2020-04-29 5:20 Robin H. Johnson
2020-04-29 5:20 Robin H. Johnson
2020-04-29 5:20 Robin H. Johnson
2020-04-28 23:21 Robin H. Johnson
2020-04-28 23:21 Robin H. Johnson
2020-04-28 17:42 Robin H. Johnson
2020-04-28 17:34 Robin H. Johnson
2020-04-28 16:46 Robin H. Johnson
2020-04-28 7:54 Robin H. Johnson
2018-12-15 18:57 Alec Warner
2016-11-05 18:02 Robin H. Johnson
2014-02-12 3:44 Jeremy Olexa
2013-08-28 2:28 Alec Warner
2013-08-27 9:08 Alec Warner
2012-12-25 17:22 Jeremy Olexa
2012-12-22 10:46 Jeremy Olexa
2012-09-18 16:17 Jeremy Olexa
2012-06-20 21:05 Jeremy Olexa
2012-02-24 18:45 Jeremy Olexa
2011-06-02 13:48 Jeremy Olexa
2011-05-19 15:09 Jeremy Olexa
2011-05-19 15:09 Jeremy Olexa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1679502574.a8e55ea71ba5602d791561c105310a53566f0503.robbat2@gentoo \
--to=robbat2@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox