forked from miyagawa/Twiggy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Twiggy.pm
134 lines (80 loc) · 2.75 KB
/
Twiggy.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package Twiggy;
use strict;
use warnings;
use 5.008_001;
our $VERSION = '0.1010';
1;
__END__
=head1 NAME
Twiggy - AnyEvent HTTP server for PSGI (like Thin)
=head1 SYNOPSIS
twiggy --listen :8080
See C<twiggy -h> for more details.
use Twiggy::Server;
my $server = Twiggy::Server->new(
host => $host,
port => $port,
);
$server->register_service($app);
AE::cv->recv;
=head1 DESCRIPTION
Twiggy is a lightweight and fast HTTP server with unique features such
as:
=over 4
=item PSGI
Can run any PSGI applications. Fully supports I<psgi.nonblocking> and
I<psgi.streaming> interfaces.
=item AnyEvent
This server uses AnyEvent and runs in a non-blocking event loop, so
it's best to run event-driven web applications that runs I/O bound
jobs or delayed responses such as long-poll, WebSocket or streaming
content (server push).
This software used to be called Plack::Server::AnyEvent but was
renamed to Twiggy. See L</NAMING> for details.
=item Fast header parser
Uses XS/C based HTTP header parser for the best performance. (optional,
install the L<HTTP::Parser::XS> module to enable it; see also
L<Plack::HTTPParser> for more information).
=item Lightweight and Fast
The memory required to run twiggy is 6MB and it can serve more than
4500 req/s with a single process on Perl 5.10 with MacBook Pro 13"
late 2009.
=item Superdaemon aware
Supports L<Server::Starter> for hot deploy and
graceful restarts.
To use it, instead of the usual:
plackup --server Twiggy --port 8111 app.psgi
install L<Server::Starter> and use:
start_server --port 8111 plackup --server Twiggy app.psgi
=back
=head1 ENVIRONMENT
The following environment variables are supported.
=over 4
=item TWIGGY_DEBUG
Set to true to enable debug messages from Twiggy.
=back
=head1 NAMING
=head2 Twiggy?
Because it is like L<Thin|http://code.macournoyer.com/thin/>, Ruby's
Rack web server using EventMachine. You know, Twiggy is thin :)
=head2 Why the cute name instead of more descriptive namespace? Are you on drugs?
I'm sick of naming Perl software like
HTTP::Server::PSGI::How::Its::Written::With::What::Module and people
call it HSPHIWWWM on IRC. It's hard to say on speeches and newbies
would ask questions what they stand for every day. That's crazy.
This module actually includes the longer alias and an empty subclass
L<AnyEvent::Server::PSGI> for those who like to type more ::'s. It
would actually help you find this software by searching for I<PSGI
Server AnyEvent> on CPAN, which i believe is a good thing.
Yes, maybe I'm on drugs. We'll see.
=head1 LICENSE
This module is licensed under the same terms as Perl itself.
=head1 AUTHOR
Tatsuhiko Miyagawa
Tokuhiro Matsuno
Yuval Kogman
Hideki Yamamura
Daisuke Maki
=head1 SEE ALSO
L<Plack> L<AnyEvent> L<Tatsumaki>
=cut