Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit e4ae7ebc194c4c3071b100e2ec44ab5075a76eb5 @miyagawa committed Jan 12, 2010
Showing with 333 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +2 −0 .shipit
  3. +4 −0 Changes
  4. +32 −0 MANIFEST
  5. +14 −0 MANIFEST.SKIP
  6. +16 −0 Makefile.PL
  7. +47 −0 README
  8. +22 −0 bin/nomo
  9. +77 −0 lib/Nomo.pm
  10. +12 −0 lib/Nomo/Engine/HTTPServer.pm
  11. +10 −0 lib/Nomo/Engine/HTTPServer/Prefork.pm
  12. +28 −0 lib/Nomo/Engine/HTTPServer/ServerStarter.pm
  13. +38 −0 lib/Nomo/Loader.pm
  14. +4 −0 t/00_compile.t
  15. +5 −0 xt/perlcritic.t
  16. +4 −0 xt/pod.t
  17. +9 −0 xt/podspell.t
  18. +4 −0 xt/synopsis.t
@@ -0,0 +1,5 @@
+META.yml
+Makefile
+inc/
+pm_to_blib
+*~
@@ -0,0 +1,2 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
+git.push_to = origin
@@ -0,0 +1,4 @@
+Revision history for Perl extension Nomo
+
+0.01 Tue Jan 12 01:31:31 2010
+ - original version
@@ -0,0 +1,32 @@
+.gitignore
+Changes
+inc/Module/Install.pm
+inc/Module/Install/AuthorTests.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/ReadmeFromPod.pm
+inc/Module/Install/Repository.pm
+inc/Module/Install/TestBase.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+inc/Spiffy.pm
+inc/Test/Base.pm
+inc/Test/Base/Filter.pm
+inc/Test/Builder.pm
+inc/Test/Builder/Module.pm
+inc/Test/More.pm
+inc/Test/Requires.pm
+lib/Nomo.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/00_compile.t
+xt/perlcritic.t
+xt/pod.t
+xt/podspell.t
+xt/synopsis.t
@@ -0,0 +1,14 @@
+\bRCS\b
+\bCVS\b
+\.svn/
+\.git/
+^MANIFEST\.
+^Makefile$
+~$
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+\.shipit
@@ -0,0 +1,16 @@
+use inc::Module::Install;
+name 'Nomo';
+all_from 'lib/Nomo.pm';
+readme_from 'lib/Nomo.pm';
+build_requires 'Test::More';
+use_test_base;
+requires 'Plack';
+requires 'Parallel::Prefork';
+requires 'HTTP::Parser::XS';
+requires 'AnyEvent';
+requires 'Server::Starter';
+test_requires 'Test::Requires';
+auto_include_deps;
+author_tests('xt');
+auto_set_repository;
+WriteAll;
47 README
@@ -0,0 +1,47 @@
+NAME
+ Nomo - High performance, starter-aware and preforking PSGI web server
+
+SYNOPSIS
+ # preforking HTTP server
+ % nomo --max-workers 20 app.psgi
+
+ # run with Server::Starter superdaemon
+ % server_starter --port 127.0.0.1:80 -- nomo --max-workers 32 app.psgi
+
+DESCRIPTION
+ Nomo is a collection of unique Web servers, that are:
+
+ High Performance
+ Heavily uses XS to use C extensions to parse XS headers and use
+ sendfile(2) to serve static files if available.
+
+ Preforking
+ Runs servers preforked like most high performance UNIX servers do.
+ This means your applications are preloaded to be copy-on-write
+ friendly.
+
+ Superdaemon aware
+ Automatically detect superdaemon such as Server::Starter and
+ ControlFreak for hot-deploy and UNIX socket sharing.
+
+ PSGI compatible
+ Can run any PSGI applications and frameworks.
+
+NOMO?
+ The name Nomo is taken from the baseball player <Hideo Nomo>, who is a
+ great starter, famous for his forkball and whose nickname is Tornado.
+
+AUTHORS
+ Tatsuhiko Miyagawa
+
+ Kazuho Oku
+
+ Daisuke Maki
+
+LICENSE
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+SEE ALSO
+ Plack HTTP::Server::PSGI::Prefork
+
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use strict;
+use lib "lib";
+use Plack::Runner;
+
+Plack::Runner->run("--server", "+Nomo::Loader", @ARGV);
+
+__END__
+
+=head1 NAME
+
+nomo - Nomo frontend
+
+=head1 SYNOPSIS
+
+ # TBD
+
+See plackup --help for more options.
+
+=cut
+
+
@@ -0,0 +1,77 @@
+package Nomo;
+
+use strict;
+use 5.008_001;
+our $VERSION = '0.01';
+
+1;
+__END__
+
+=encoding utf-8
+
+=for stopwords
+
+=head1 NAME
+
+Nomo - High performance, starter-aware and preforking PSGI web server
+
+=head1 SYNOPSIS
+
+ # preforking HTTP server
+ % nomo --max-workers 20 app.psgi
+
+ # run with Server::Starter superdaemon
+ % server_starter --port 127.0.0.1:80 -- nomo --max-workers 32 app.psgi
+
+=head1 DESCRIPTION
+
+Nomo is a collection of unique Web servers, that are:
+
+=over 4
+
+=item High Performance
+
+Heavily uses XS to use C extensions to parse XS headers and use
+sendfile(2) to serve static files if available.
+
+=item Preforking
+
+Runs servers preforked like most high performance UNIX servers
+do. This means your applications are preloaded to be copy-on-write
+friendly.
+
+=item Superdaemon aware
+
+Automatically detect superdaemon such as Server::Starter and
+ControlFreak for hot-deploy and UNIX socket sharing.
+
+=item PSGI compatible
+
+Can run any PSGI applications and frameworks.
+
+=back
+
+=head1 NOMO?
+
+The name Nomo is taken from the baseball player
+L<Hideo Nomo|http://en.wikipedia.org/wiki/Hideo_Nomo>, who is a great
+starter, famous for his forkball and whose nickname is Tornado.
+
+=head1 AUTHORS
+
+Tatsuhiko Miyagawa
+
+Kazuho Oku
+
+Daisuke Maki
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<Plack> L<HTTP::Server::PSGI::Prefork>
+
+=cut
@@ -0,0 +1,12 @@
+package Nomo::Engine::HTTPServer;
+use strict;
+use Plack::Util;
+
+sub new {
+ my($class, %opts) = @_;
+
+ my $parent = $opts{parent} || "HTTP::Server::PSGI";
+ Plack::Util::load_class($parent)->new(%opts);
+}
+
+1;
@@ -0,0 +1,10 @@
+package Nomo::Engine::HTTPServer::Prefork;
+use strict;
+
+sub wrap {
+ my($class, $cb, $opts) = @_;
+ $opts->{parent} = "HTTP::Server::PSGI::Prefork";
+ $cb->(%$opts);
+}
+
+1;
@@ -0,0 +1,28 @@
+package Nomo::Engine::HTTPServer::ServerStarter;
+use strict;
+use Server::Starter;
+
+sub wrap {
+ my($class, $cb, $opts) = @_;
+
+ my ($hostport, $fd) = %{Server::Starter::server_ports()};
+ if ($hostport =~ /(.*):(\d+)/) {
+ $opts->{host} = $1;
+ $opts->{port} = $2;
+ } else {
+ $opts->{port} = $hostport;
+ }
+
+ my $server = $cb->(%$opts);
+
+ $server->{listen_sock} = IO::Socket::INET->new(
+ Proto => 'tcp',
+ ) or die "failed to create socket:$!";
+
+ $server->{listen_sock}->fdopen($fd, 'w')
+ or die "failed to bind to listening socket:$!";
+
+ $server;
+}
+
+1;
@@ -0,0 +1,38 @@
+package Nomo::Loader;
+use strict;
+use Plack::Util;
+
+sub build(&$;$) {
+ my($builder, $cb, $opts) = @_;
+ sub { $builder->($cb, $opts) };
+}
+
+sub new {
+ my($class, %opts) = @_;
+
+ my $engine = $opts{engine} || "HTTPServer"; # TODO support AnyEvent
+ my $workers = $opts{max_workers} || 32;
+
+ my $server_class = Plack::Util::load_class($engine, "Nomo::Engine");
+ my $server = sub { $server_class->new(@_) };
+
+ my @wrappers;
+ push @wrappers, "Prefork" if $workers > 1;
+ push @wrappers, "ServerStarter" if $ENV{SERVER_STARTER_PORT};
+
+ for my $wrapper (@wrappers) {
+ my $wrapper_class = Plack::Util::load_class($wrapper, "Nomo::Engine::$engine");
+ $server = build { $wrapper_class->wrap(@_) } $server, \%opts;
+ }
+
+ bless { server => $server, opts => \%opts }, $class;
+}
+
+sub run {
+ my($self, $app) = @_;
+
+ my $server = $self->{server}->(%{$self->{opts}});
+ $server->run($app);
+}
+
+1;
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Nomo' }
@@ -0,0 +1,5 @@
+use strict;
+use Test::More;
+eval q{ use Test::Perl::Critic };
+plan skip_all => "Test::Perl::Critic is not installed." if $@;
+all_critic_ok("lib");
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
@@ -0,0 +1,9 @@
+use Test::More;
+eval q{ use Test::Spelling };
+plan skip_all => "Test::Spelling is not installed." if $@;
+add_stopwords(<DATA>);
+set_spell_cmd("aspell -l en list");
+all_pod_files_spelling_ok('lib');
+__DATA__
+Tatsuhiko
+Miyagawa
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Synopsis";
+plan skip_all => "Test::Synopsis required" if $@;
+all_synopsis_ok();

0 comments on commit e4ae7eb

Please sign in to comment.