Permalink
Browse files

Rewrote Nomo using Catalyst::Engine::HTTP::Prefork as a base code.

  • Loading branch information...
1 parent 3b41466 commit f8bdf60c43f4592c424ad94e5d74a3d0da6380e3 @miyagawa committed Feb 9, 2010
View
@@ -3,11 +3,15 @@ name 'Nomo';
all_from 'lib/Nomo.pm';
readme_from 'lib/Nomo.pm';
build_requires 'Test::More';
-use_test_base;
-requires 'Plack', 0.9032;
-requires 'Parallel::Prefork';
-requires 'HTTP::Parser::XS';
-#requires 'AnyEvent';
+requires 'Plack', 0.99;
+requires 'Net::Server';
+requires 'Net::Server::SS::Prefork';
+requires 'Data::Dump';
+requires 'HTTP::HeaderParser::XS';
+requires 'HTTP::Status';
+requires 'HTTP::Date';
+requires 'URI::Escape';
+
recommends 'Server::Starter';
test_requires 'Test::Requires';
auto_include_deps;
View
64 README
@@ -1,68 +1,52 @@
NAME
- Nomo - High performance, starter-aware and preforking PSGI web server
+ Nomo - High-performance preforking PSGI web server
SYNOPSIS
- # preforking HTTP server
- % nomo --max-workers 20 app.psgi
+ # Run app.psgi with the default settings
+ > nomo
- # run with Server::Starter superdaemon
- % server_starter --port 127.0.0.1:80 -- nomo --max-workers 32 app.psgi
+ # run with Server::Starter
+ > start_server --port 127.0.0.1:80 -- nomo --max-servers 32 myapp.psgi
+
+ # UNIX domain sockets
+ > nomo --listen /tmp/nomo.sock
DESCRIPTION
Nomo is a PSGI perl web server that has unique features such as:
High Performance
- Uses XS/C extensions to parse HTTP headers for the best performance.
+ Uses the fast XS/C HTTP header parser
Preforking
Runs servers preforked like most high performance UNIX servers do.
- This means your applications are preloaded to be copy-on-write
- friendly.
-
- It also means your application can be blocking, and load-balancing
- is handled by kernels. No requests piled up behind busy workers.
Superdaemon aware
- Automatically detect superdaemon such as Server::Starter and
- ControlFreak to benefit from their features such as hot deploy,
- graceful restarts, dynamic worker pool configuration and sharing
- UNIX Domain sockets.
+ Supports Server::Starter for hot deploy and graceful restarts.
- UNIX only
- Optimized for UNIX for the best performance by avoiding weird Win32
- compatible code.
+ UNIX Domain Socket support
+ Forked children share the UNIX domain socket with the parent process
+ for the best performance when used with the nginx proxy in front.
PSGI compatible
- Can run any PSGI applications and frameworks.
-
- Daemon mode
- Can use "--daemonize" and "--pid" to become daemon just like normal
- UNIX tools, but can also be used with other supervisor tools such as
- daemontools or supervisord.
-
- Features that are planned but not implemented are:
-
- Reaping dead workers
- Log rotation via signals
- Listening to UNIX domain sockets
- Perl DSL configuration
- Per worker hooks
+ 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.
+ HTTP/1.1 support
+ Supports chunked requests and responses, keep-alive and pipeline
+ requests.
-AUTHORS
- Tatsuhiko Miyagawa
+AUTHOR
+ Tatsuhiko Miyagawa <miyagawa@bulknews.net>
- Kazuho Oku
+ Andy Grundman wrote Catalyst::Engine::HTTP::Prefork, which this module
+ is heavily based on.
- Daisuke Maki
+ Kazuho Oku wrote Net::Server::SS::PreFork that makes easy to add
+ Server::Starter support to this software.
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
+ Plack Catalyst::Engine::HTTP::Prefork Net::Server::Prefork
View
@@ -1,22 +1,28 @@
#!/usr/bin/perl
use strict;
use lib "lib";
-use Nomo::Runner;
+use Plack::Runner;
-Nomo::Runner->run("--server", "+Nomo::Loader", @ARGV);
+my $runner = Plack::Runner->new(server => 'Nomo', env => 'production');
+$runner->parse_options(@ARGV);
+$runner->run;
__END__
=head1 NAME
-nomo - Nomo frontend
+nomo - Nomo launcher
=head1 SYNOPSIS
- # TBD
+ nomo --port 8081
+ nomo --socket /tmp/nomo.sock
+ nomo --max-servers 32
-See plackup --help for more options.
+See `plackup -h` for more options.
-=cut
+=head1 SEE ALSO
+L<Nomo>
+=cut
View
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-
-use AnyEvent;
-use Plack::Util;
-use ControlFreak::Proxy::Process;
-use Nomo::Loader;
-
-$ENV{NOMO_USE_CONTROLFREAK} = 1;
-
-my $app_psgi = $ARGV[0] || "app.psgi";
-my $app = Plack::Util::load_psgi($app_psgi);
-
-my $cfd = $ENV{_CFK_COMMAND_FD} or die "no command fd";
-my $sfd = $ENV{_CFK_STATUS_FD} or die "no status fd";
-my $lfd = $ENV{_CFK_LOG_FD} or die "no log fd";
-
-open my $cfh, "<&=$cfd"
- or die "Cannot open Command filehandle, is descriptor correct?";
-
-open my $sfh, ">>&=$sfd"
- or die "Cannot open Status filehandle, is descriptor correct?";
-
-open my $lfh, ">>&=$lfd"
- or die "Cannot open Status filehandle, is descriptor correct?";
-
-trap_sigs();
-
-my $sockets = ControlFreak::Proxy::Process->sockets_from_env;
-
-my $proxy = ControlFreak::Proxy::Process->new(
- command_fh => $cfh,
- status_fh => $sfh,
- log_fh => $lfh,
- sockets => $sockets,
- svc_coderef => sub {
- Nomo::Loader->new->run($app),
- },
-);
-
-$proxy->{app} = $app;
-
-$proxy->log('out', "$0 proxy started");
-$proxy->run;
-
-sub trap_sigs {
- $SIG{HUP} = $SIG{INT} = $SIG{TERM} = sub {
- my $sig = shift;
- if ($proxy) {
- $proxy->log("err", "Got signal $sig");
- $proxy->shutdown;
- }
- exit 0;
- };
- $SIG{__WARN__} = sub {
- my $warn = shift || "";
- $proxy->log("err", "warn $warn") if $proxy;
- };
- $SIG{__DIE__} = sub {
- my $reason = shift || "";
- return if $^S;
- $proxy->log("err", "die $reason") if $proxy;
- exit -1;
- };
-}
View
@@ -1,25 +0,0 @@
-console full=yes
-console address=127.0.0.1:4000
-
-socket httpsock host=127.0.0.1
-socket httpsock service=5000
-
-proxy httpproxy cmd=nomo-cfk app.psgi
-proxy httpproxy service nomo1 cmd=nomo1
-proxy httpproxy service nomo1 tie_stdin_to=httpsock
-proxy httpproxy service nomo2 cmd=nomo2
-proxy httpproxy service nomo2 tie_stdin_to=httpsock
-proxy httpproxy service nomo3 cmd=nomo3
-proxy httpproxy service nomo3 tie_stdin_to=httpsock
-proxy httpproxy service nomo4 cmd=nomo4
-proxy httpproxy service nomo4 tie_stdin_to=httpsock
-proxy httpproxy service nomo5 cmd=nomo5
-proxy httpproxy service nomo5 tie_stdin_to=httpsock
-
-command bind httpsock
-command pup httpproxy
-command up service nomo1
-command up service nomo2
-command up service nomo3
-command up service nomo4
-command up service nomo5
View
@@ -13,15 +13,18 @@ __END__
=head1 NAME
-Nomo - High performance, starter-aware and preforking PSGI web server
+Nomo - High-performance preforking PSGI web server
=head1 SYNOPSIS
- # preforking HTTP server
- % nomo --max-workers 20 app.psgi
+ # Run app.psgi with the default settings
+ > nomo
- # run with Server::Starter superdaemon
- % server_starter --port 127.0.0.1:80 -- nomo --max-workers 32 app.psgi
+ # run with Server::Starter
+ > start_server --port 127.0.0.1:80 -- nomo --max-servers 32 myapp.psgi
+
+ # UNIX domain sockets
+ > nomo --listen /tmp/nomo.sock
=head1 DESCRIPTION
@@ -31,70 +34,40 @@ Nomo is a PSGI perl web server that has unique features such as:
=item High Performance
-Uses XS/C extensions to parse HTTP headers for the best performance.
+Uses the fast XS/C HTTP header parser
=item Preforking
-Runs servers preforked like most high performance UNIX servers
-do. This means your applications are preloaded to be copy-on-write
-friendly.
-
-It also means your application can be blocking, and load-balancing is
-handled by kernels. No requests piled up behind busy workers.
+Runs servers preforked like most high performance UNIX servers do.
=item Superdaemon aware
-Automatically detect superdaemon such as Server::Starter and
-ControlFreak to benefit from their features such as hot deploy,
-graceful restarts, dynamic worker pool configuration and sharing UNIX
-Domain sockets.
+Supports L<Server::Starter> for hot deploy and graceful restarts.
-=item UNIX only
+=item UNIX Domain Socket support
-Optimized for UNIX for the best performance by avoiding weird Win32
-compatible code.
+Forked children share the UNIX domain socket with the parent process
+for the best performance when used with the nginx proxy in front.
=item PSGI compatible
-Can run any PSGI applications and frameworks.
-
-=item Daemon mode
-
-Can use C<--daemonize> and C<--pid> to become daemon just like normal
-UNIX tools, but can also be used with other supervisor tools such as
-daemontools or supervisord.
-
-=back
-
-Features that are planned but not implemented are:
+Can run any PSGI applications and frameworks
-=over 4
-
-=item Reaping dead workers
-
-=item Log rotation via signals
-
-=item Listening to UNIX domain sockets
+=item HTTP/1.1 support
-=item Perl DSL configuration
-
-=item Per worker hooks
+Supports chunked requests and responses, keep-alive and pipeline requests.
=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
+=head1 AUTHOR
-Tatsuhiko Miyagawa
+Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
-Kazuho Oku
+Andy Grundman wrote L<Catalyst::Engine::HTTP::Prefork>, which this module
+is heavily based on.
-Daisuke Maki
+Kazuho Oku wrote L<Net::Server::SS::PreFork> that makes it easy to add
+L<Server::Starter> support to this software.
=head1 LICENSE
@@ -103,6 +76,6 @@ it under the same terms as Perl itself.
=head1 SEE ALSO
-L<Plack> L<HTTP::Server::PSGI::Prefork>
+L<Plack> L<Catalyst::Engine::HTTP::Prefork> L<Net::Server::Prefork>
=cut
@@ -1,12 +0,0 @@
-package Nomo::Engine::HTTPServer;
-use strict;
-use Plack::Util;
-use HTTP::Parser::XS;
-use HTTP::Server::PSGI;
-
-sub new {
- my($class, %opts) = @_;
- HTTP::Server::PSGI->new(%opts);
-}
-
-1;
@@ -1,17 +0,0 @@
-package Nomo::Engine::HTTPServer::ControlFreak;
-use strict;
-
-sub wrap {
- my($class, $cb, $options) = @_;
-
- my $server = $cb->($options);
-
- open my $socket, "<&=0"
- or die "Cannot open stdin: $!";
- bless $socket, "IO::Socket::INET";
- $server->{listen_sock} = $socket;
-
- $server;
-}
-
-1;
Oops, something went wrong.

0 comments on commit f8bdf60

Please sign in to comment.