Skip to content

Instantly share code, notes, and snippets.

@wakaba
Created September 27, 2012 09:52
Show Gist options
  • Save wakaba/3793197 to your computer and use it in GitHub Desktop.
Save wakaba/3793197 to your computer and use it in GitHub Desktop.
*~
/deps/
/local/
/perl
/prove
/plackup
/Makefile.setupenv
/cin
/config/perl/libs.txt
[submodule "modules/test-anyevent-plackup"]
path = modules/test-anyevent-plackup
url = git://github.com/wakaba/perl-test-anyevent-plackup
WGET = wget
PERL = perl
GIT = git
PERL_VERSION = 5.16.1
PERL_ENV = PATH="$(abspath local/perlbrew/perls/perl-$(PERL_VERSION)/bin):$(abspath local/perl-$(PERL_VERSION)/pm/bin):$(PATH)"
all:
deps: git-submodules local-perl pmbp-install
git-submodules:
$(GIT) submodule update --init
local/bin/pmbp.pl: always
mkdir -p local/bin
$(WGET) -O $@ https://github.com/wakaba/perl-setupenv/raw/master/bin/pmbp.pl
local-perl: local/bin/pmbp.pl
$(PERL_ENV) $(PERL) local/bin/pmbp.pl --perl-version $(PERL_VERSION) --install-perl
pmbp-update: local/bin/pmbp.pl
$(PERL_ENV) $(PERL) local/bin/pmbp.pl --update
pmbp-install: local/bin/pmbp.pl
$(PERL_ENV) $(PERL) local/bin/pmbp.pl --install \
--create-perl-command-shortcut perl \
--create-perl-command-shortcut plackup
always:
AnyEvent
AnyEvent::HTTP
Starlet
Twiggy
AnyEvent~7.02
common::sense~3.6
AnyEvent::HTTP~2.14
Compress::Raw::Zlib~2.056
Compress::Raw::Bzip2~2.055
HTML::Tagset~3.20
Test::NoWarnings~1.04
Test::Tester~0.108
IO::Compress::Bzip2~2.055
HTML::Parser~3.69
HTTP::Date~6.02
Encode::Locale~1.03
LWP::MediaTypes~6.02
WWW::RobotRules~6.02
HTTP::Cookies~6.01
Net::HTTP~6.03
HTTP::Daemon~6.01
File::Listing~6.04
HTTP::Negotiate~6.01
Class::Inspector~1.27
Test::Deep~0.110
HTTP::Headers~6.00
Devel::StackTrace::AsHTML~0.11
Filesys::Notify::Simple~0.08
LWP::UserAgent~6.04
File::ShareDir~1.03
HTTP::Body~1.15
Devel::StackTrace~1.27
URI~1.60
Hash::MultiValue~0.12
Test::SharedFork~0.20
Test::More~0.98
Plack~1.0004
Test::TCP~1.17
Try::Tiny~0.11
Test::Requires~0.06
Twiggy~0.1020
Path::Class~0.26
Perl::OSType~1.002
Class::Accessor::Lite~0.05
List::MoreUtils~0.33
ExtUtils::CBuilder~0.280205
Scope::Guard~0.20
Proc::Wait3~0.04
Parallel::Prefork~0.13
Server::Starter~0.12
ExtUtils::MakeMaker~6.62
Starlet~0.16
Data::Dump~1.21
HTTP::Parser::XS~0.14
Net::Server~2.006
Starman~0.3003
parent~0.225
File::Temp~0.22
ExtUtils::Constant~0.23
Socket~2.006
use strict;
use warnings;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib glob file(__FILE__)->dir->parent->subdir('modules', '*', 'lib')->stringify;
use Test::AnyEvent::plackup;
use AnyEvent;
use AnyEvent::HTTP;
my $cv = AE::cv;
my $server = Test::AnyEvent::plackup->new;
$server->server('Starlet');
$server->plackup('local/perl-5.10.1/pm/bin/plackup');
$server->set_app_code(q{
return sub {
return sub {
my $writer = $_[0]->([200, []]);
for my $i (1..20) {
$writer->write("$i\n");
warn "SERVER: $i\n";
sleep 1;
}
$writer->close;
undef $watcher;
};
};
});
my ($start_cv, $stop_cv) = $server->start_server;
$start_cv->cb(sub {
warn "Started";
my $url = 'http://localhost:' . $server->port . '/';
http_get $url, on_body => sub {
warn "CLIENT: $_[0]";
return 0 if $_[0] == 5;
return 1;
}, sub {
my $timer; $timer = AE::timer 5, 0, sub {
$server->stop_server;
undef $timer;
};
};
});
$stop_cv->cb(sub {
warn "Stopped";
$cv->send;
});
$cv->recv;
use strict;
use warnings;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib glob file(__FILE__)->dir->parent->subdir('modules', '*', 'lib')->stringify;
use Test::AnyEvent::plackup;
use AnyEvent;
use AnyEvent::HTTP;
my $cv = AE::cv;
my $server = Test::AnyEvent::plackup->new;
$server->server('Twiggy');
$server->plackup('local/perl-5.10.1/pm/bin/plackup');
$server->set_app_code(q{
use AnyEvent;
return sub {
return sub {
my $writer = $_[0]->([200, []]);
my $i = 0;
my $watcher; $watcher = AE::timer 0, 1, sub {
$i++;
eval {
$writer->write("$i\n");
1;
} or warn "SERVER ERROR: $@";
warn "SERVER: $i\n";
$writer->close, undef $watcher if $i > 20;
};
};
};
});
my ($start_cv, $stop_cv) = $server->start_server;
$start_cv->cb(sub {
warn "Started";
my $url = 'http://localhost:' . $server->port . '/';
http_get $url, on_body => sub {
warn "CLIENT: $_[0]";
return 0 if $_[0] == 5;
return 1;
}, sub {
my $timer; $timer = AE::timer 5, 0, sub {
$server->stop_server;
undef $timer;
};
};
});
$stop_cv->cb(sub {
warn "Stopped";
$cv->send;
});
$cv->recv;
use strict;
use warnings;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib glob file(__FILE__)->dir->parent->subdir('modules', '*', 'lib')->stringify;
use Test::AnyEvent::plackup;
use AnyEvent;
use AnyEvent::HTTP;
my $cv = AE::cv;
my $server = Test::AnyEvent::plackup->new;
$server->server('Twiggy::Prefork');
$server->plackup('local/perl-latest/pm/bin/plackup');
$server->set_app_code(q{
use AnyEvent;
return sub {
return sub {
my $writer = $_[0]->([200, []]);
my $i = 0;
my $watcher; $watcher = AE::timer 0, 1, sub {
$i++;
eval {
$writer->write("$i\n");
1;
} or warn "SERVER ERROR: $@";
warn "SERVER: $i\n";
$writer->close, undef $watcher if $i > 20;
};
};
};
});
my ($start_cv, $stop_cv) = $server->start_server;
$start_cv->cb(sub {
warn "Started";
my $url = 'http://localhost:' . $server->port . '/';
http_get $url, on_body => sub {
warn "CLIENT: $_[0]";
return 0 if $_[0] == 5;
return 1;
}, sub {
my $timer; $timer = AE::timer 5, 0, sub {
$server->stop_server;
undef $timer;
};
};
});
$stop_cv->cb(sub {
warn "Stopped";
$cv->send;
});
$cv->recv;
use strict;
use warnings;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib glob file(__FILE__)->dir->parent->subdir('modules', '*', 'lib')->stringify;
use Test::AnyEvent::plackup;
use AnyEvent;
use AnyEvent::HTTP;
my $cv = AE::cv;
my $server = Test::AnyEvent::plackup->new;
$server->server('Twiggy');
$server->plackup('local/perl-5.10.1/pm/bin/plackup');
$server->set_app_code(q{
use AnyEvent;
return sub {
return sub {
my $writer = $_[0]->([200, []]);
my $i = 0;
my $watcher; $watcher = AE::timer 0, 1, sub {
$i++;
$writer->write("$i\n");
warn "SERVER: $i\n";
$writer->close, undef $watcher if $i > 20;
};
};
};
});
my ($start_cv, $stop_cv) = $server->start_server;
$start_cv->cb(sub {
warn "Started";
my $url = 'http://localhost:' . $server->port . '/';
http_get $url, on_body => sub {
warn "CLIENT: $_[0]";
return 0 if $_[0] == 5;
return 1;
}, sub {
my $timer; $timer = AE::timer 5, 0, sub {
$server->stop_server;
undef $timer;
};
};
});
$stop_cv->cb(sub {
warn "Stopped";
$cv->send;
});
$cv->recv;
$ PERL5LIB="`cat config/perl/libs.txt`" perl bin/server-starlet.pl
Started at bin/server-starlet.pl line 34.
127.0.0.1 - - [27/Sep/2012:18:58:27 +0900] "GET / HTTP/1.1" 200 - "http://localhost:2070/" "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/2.14; +http://software.schmorp.de/pkg/AnyEvent)"
SERVER: 1
CLIENT: 1
SERVER: 2
CLIENT: 2
SERVER: 3
CLIENT: 3
SERVER: 4
CLIENT: 4
SERVER: 5
CLIENT: 5
SERVER: 6
SERVER: 7
SERVER: 8
SERVER: 9
SERVER: 10
SERVER: 11
SERVER: 12
SERVER: 13
SERVER: 14
SERVER: 15
SERVER: 16
SERVER: 17
SERVER: 18
SERVER: 19
SERVER: 20
Stopped at bin/server-starlet.pl line 50.
$ PERL5LIB="`cat config/perl/libs.txt`" perl bin/server-twiggy-eval.pl
Started at bin/server-twiggy-eval.pl line 38.
127.0.0.1 - - [27/Sep/2012:19:18:23 +0900] "GET / HTTP/1.1" 200 - "http://localhost:3970/" "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/2.14; +http://software.schmorp.de/pkg/AnyEvent)"
SERVER: 1
CLIENT: 1
SERVER: 2
CLIENT: 2
SERVER: 3
CLIENT: 3
SERVER: 4
CLIENT: 4
SERVER: 5
CLIENT: 5
SERVER: 6
SERVER ERROR: AnyEvent::Handle uncaught error: パイプが切断されました at /home/wakaba/apps/connectionclosedtest/local/perl-5.10.1/pm/lib/perl5/Twiggy/Server.pm line 601
SERVER: 7
SERVER: 8
SERVER: 9
SERVER: 10
Stopped at bin/server-twiggy-eval.pl line 54.
$ PERL5LIB="`cat config/perl/libs.txt`" perl bin/server-twiggy.pl
Started at bin/server-twiggy.pl line 35.
127.0.0.1 - - [27/Sep/2012:18:59:33 +0900] "GET / HTTP/1.1" 200 - "http://localhost:1186/" "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/2.14; +http://software.schmorp.de/pkg/AnyEvent)"
SERVER: 1
CLIENT: 1
SERVER: 2
CLIENT: 2
SERVER: 3
CLIENT: 3
SERVER: 4
CLIENT: 4
SERVER: 5
CLIENT: 5
SERVER: 6
AnyEvent::Handle uncaught error: パイプが切断されました at /home/wakaba/apps/connectionclosedtest/local/perl-5.10.1/pm/lib/perl5/Twiggy/Server.pm line 601
Can't start plackup: 8192 at modules/test-anyevent-plackup/lib/Test/AnyEvent/plackup.pm line 187.
Stopped at bin/server-twiggy.pl line 51.
Detected (possibly) memory leak at modules/test-anyevent-plackup/lib/Test/AnyEvent/plackup.pm line 209 during global destruction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment