Created
July 20, 2011 09:58
-
-
Save dolmen/1094704 to your computer and use it in GitHub Desktop.
Apple Store check, using AnyEvent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# AnyEvent version of https://gist.github.com/1094658 | |
use 5.010; | |
use strict; | |
use warnings; | |
use AnyEvent; | |
use AnyEvent::HTTP; | |
my $w; | |
$w = AE::timer 0, 10, sub { | |
http_head "http://store.apple.com", sub { | |
my ($data, $headers) = @_; | |
if ($headers->{Status} == 404) { | |
say "Apple Store is down!" | |
} else { | |
say "Apple Store back up!" | |
} | |
}; | |
}; | |
my $cv = AE::cv; | |
my $brk = AE::signal 'INT', sub { $cv->send }; | |
$cv->recv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment