• Like
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
Upcoming SlideShare
Loading in...5
×

エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -

  • 5,593 views
Uploaded on

エロサイト管理者の憂鬱3 …

エロサイト管理者の憂鬱3
Hokkaido.pm#4 のの発表資料です。

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,593
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
15
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. ./!"" repo#   !"" Changes#   !"" MANIFEST.SKIP#   !"" Makefile.PL#   !"" README#   !"" lib#   #   %"" SampleApp.pm#   !"" t#   #   %"" 00_compile.t#   %"" xt#   !"" 01_podspell.t#   !"" 02_perlcritic.t#   !"" 03_pod.t#   %"" perlcriticrc%"" sandbox
  • 2. ./lib!"" SampleApp#   !"" CLI#   #   %"" Crawler.pm#   !"" Role.pm use Mouse::Role;#   %"" Web#   !"" API.pm use Mouse; with “SampleApp::Role”;#   %"" Controller#   %"" Root.pm $c->model(“API”)->get_entries();%"" SampleApp.pm
  • 3. use LWP::UserAgent;use Email::Sender::Simple qw(sendmail);use Email::MIME;use Try::Tiny;use YAML qw(LoadFile);use Path::Class qw( file );my $file = $ARGV[0] || "config.yaml";die "Cant open $file" unless ( -f file($file)->stringify );my $config = LoadFile( file($file) );my $ua = LWP::UserAgent->new( agent => Monita/0.01, timeout => 30 );for my $url ( @{ $config->{url} } ) { my $res = $ua->get($url); send_report( $res ) unless $res->is_success;}sub send_report { my $res = shift; my $email = Email::MIME->create( header => [ From => $config->{from}, To => $config->{to}, Subject => $res->request->uri . : . $res->code, ], attributes => { content_type => text/plain, }, body => $res->status_line, ); try { sendmail($email) } catch { my $error = $_; warn $error->message };}