Git Product home page Git Product logo

starman's Introduction

NAME

Starman - High-performance preforking PSGI/Plack web server

SYNOPSIS

# Run app.psgi with the default settings
> starman

# run with Server::Starter
> start_server --port 127.0.0.1:80 -- starman --workers 32 myapp.psgi

# UNIX domain sockets
> starman --listen /tmp/starman.sock

Read more options and configurations by running `perldoc starman` (lower-case s).

DESCRIPTION

Starman is a PSGI perl web server that has unique features such as:

  • High Performance

    Uses the fast XS/C HTTP header parser

  • Preforking

    Spawns workers preforked like most high performance UNIX servers do. Starman also reaps dead children and automatically restarts the worker pool.

  • Signals

    Supports HUP for graceful worker restarts, and TTIN/TTOU to dynamically increase or decrease the number of worker processes, as well as QUIT to gracefully shutdown the worker processes.

  • Superdaemon aware

    Supports Server::Starter for hot deploy and graceful restarts.

  • Multiple interfaces and UNIX Domain Socket support

    Able to listen on multiple interfaces including UNIX sockets.

  • Small memory footprint

    Preloading the applications with --preload-app command line option enables copy-on-write friendly memory management. Also, the minimum memory usage Starman requires for the master process is 7MB and children (workers) is less than 3.0MB.

  • PSGI compatible

    Can run any PSGI applications and frameworks

  • HTTP/1.1 support

    Supports chunked requests and responses, keep-alive and pipeline requests.

  • UNIX only

    This server does not support Win32.

PERFORMANCE

Here's a simple benchmark using Hello.psgi.

-- server: Starman (workers=10)
Requests per second:    6849.16 [#/sec] (mean)
-- server: Twiggy
Requests per second:    3911.78 [#/sec] (mean)
-- server: AnyEvent::HTTPD
Requests per second:    2738.49 [#/sec] (mean)
-- server: HTTP::Server::PSGI
Requests per second:    2218.16 [#/sec] (mean)
-- server: HTTP::Server::PSGI (workers=10)
Requests per second:    2792.99 [#/sec] (mean)
-- server: HTTP::Server::Simple
Requests per second:    1435.50 [#/sec] (mean)
-- server: Corona
Requests per second:    2332.00 [#/sec] (mean)
-- server: POE
Requests per second:    503.59 [#/sec] (mean)

This benchmark was processed with ab -c 10 -t 1 -k on MacBook Pro 13" late 2009 model on Mac OS X 10.6.2 with perl 5.10.0. YMMV.

NOTES

Because Starman runs as a preforking model, it is not recommended to serve the requests directly from the internet, especially when slow requesting clients are taken into consideration. It is suggested to put Starman workers behind the frontend servers such as nginx, and use HTTP proxy with TCP or UNIX sockets.

PSGI EXTENSIONS

psgix.informational

Starman exposes a callback named psgix.informational that can be used for sending an informational response. The callback accepts two arguments, the first argument being the status code and the second being an arrayref of the headers to be sent. Example below sends an 103 Early Hints response before processing the request to build a final response.

sub {
    my $env = shift;

    $env->{'psgix.informational'}->( 103, [
        "Link" => "</style.css>; rel=preload"
    ] );

    my $rest = ...
    $resp;
}

AUTHOR

Tatsuhiko Miyagawa [email protected]

Andy Grundman wrote Catalyst::Engine::HTTP::Prefork, which this module is heavily based on.

Kazuho Oku wrote Net::Server::SS::PreFork that makes it easy to add Server::Starter support to this software.

The psgix.informational callback comes from Starlet by Kazuho Oku.

COPYRIGHT

Tatsuhiko Miyagawa, 2010-

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Plack Catalyst::Engine::HTTP::Prefork Net::Server::PreFork

starman's People

Contributors

acme avatar alexmv avatar ap avatar audreyt avatar cho45 avatar clkao avatar dex4er avatar dsteinbrunner avatar gbarr avatar grantm avatar holophrastic avatar kazeburo avatar mauke avatar miyagawa avatar oalders avatar olsonanl avatar oschwald avatar pecastro avatar perlover avatar phaylon avatar pmakholm avatar podoleanuciprian avatar real-dam avatar robrwo avatar siracusa avatar slobo avatar spleenjack avatar timbunce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starman's Issues

Starman 0.4006 - many errors "write error: Broken pipe at" in error.log

Hello,

I updated Starman (0.4001 -> 0.4006) and now i see many like these errors:

2013/09/02-21:21:58 Starman::Server (type Net::Server::PreFork) starting! pid(11390)
Binding to TCP port 2003 on host XX.XX.XX.XX with IPv4
Setting gid to "501 501 501"
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 22.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 64205.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 16.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 8.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 97088.
write error: Broken pipe at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 551, <$read> line 45.

Stop supporting win32

With the switch to Milla, you can install Starman on win32 by accident, while tests will most likely fail and doesn't run correctly.

We have to inject the check of OS in Build.PL with milla before-release script.

Installation with LWP < v6 can make SSL tests fail

Installing 0.4008 runs two tests for the new SSL functionality. On a system with LWP < version 6 they will fail because IO::Socket::SSL can be missing.

I asked on IRC and it was suggested that Starman should either depend on LWP::Protocol::https 6, or IO::Socket::SSL.

My personal preference is that SSL be a totally opt-in feature, and that SSL libs are not required for a basic installation.

If you need further details, please let me know.

Document the use of rand() and File::Temp

if you use the application in the parent with --preload-app and then use modules that calls rand(), such as File::Temp, and then later in the children again, your child processes get the same stream of rand() because the seed was initialized in the parent.

Does it make sense to call srand() by Starman, or at least should we document that as a known issue?

See File::Temp/Forking for details.

Implement --preload

and make delayed loader the default, and calls psgi_app_builder in child_init_hook if it's set

reduce syscalls needed to send a response

Starman::Server::_finalize_response contains this code:

    # Buffer the headers so they are sent with the first write() call 
    # This reduces the number of TCP packets we are sending
    syswrite $conn, join( $CRLF, @headers, '' ) . $CRLF;

and later on the body is written:

syswrite $conn, $buffer;

This is doing two syscalls when only one is needed. I suggest saving the headers and prepend it to the first $buffer so for small responses only one call to write() is needed.

Unstable from freebsd.

Hi.
I have FreeBSD 8.2-PRERELEASE amd64 server (*default tag=RELENG_8)
CPU: Intel(R) Core(TM)2 Duo CPU E7400 @ 2.80GHz
real memory = 4294967296 (4096 MB)
avail memory = 4076785664 (3887 MB)

Im start myapp.pl ( Mojolicious::Lite )

/usr/local/bin/starman
-MMojolicious
-MDBI
--daemonize
--socket /tmp/socketfarm.sock
--pid /var/run/socketfarm.pid
--workers 32
--preload-app myapp.pl
--user www
--group www
--access-log ./socketfarm_access.log
--error-log ./socketfarm_error.log
--backlog 2048.

--max-requests 1000 \

--disable-keepalive \

--mode production

--listen 127.0.0.1:9000 \

and test
/usr/local/apache/bin/ab -n 1000 -c 100 http://my_domen/login/

i have many errors from log

  • - - [13/Jul/2011:11:33:54 +0400] "GET /login/ HTTP/1.0" 200 973 "-" "ApacheBench/1.3d"
  • - - [13/Jul/2011:11:33:54 +0400] "GET /login/ HTTP/1.0" 404 - "-" "ApacheBench/1.3d"

[Wed Jul 13 11:33:54 2011] [debug] 200 OK (0.002060s, 485.437/s).
[Wed Jul 13 11:33:54 2011] [debug] Rendering template "login.html.ep" from DATA section.
[Wed Jul 13 11:33:54 2011] [debug] GET /login/ (ApacheBench/1.3d).
[Wed Jul 13 11:33:54 2011] [debug] Dispatching callback.
...
[Wed Jul 13 11:33:54 2011] [debug] Dispatching callback.
[Wed Jul 13 11:33:54 2011] [debug] Template "login.html.ep" not found.
[Wed Jul 13 11:33:54 2011] [debug] 200 OK (0.001914s, 522.466/s).
[Wed Jul 13 11:33:54 2011] [debug] Template "login.html.ep" not found.
[Wed Jul 13 11:33:54 2011] [debug] GET /login/ (ApacheBench/1.3d).
...
[Wed Jul 13 11:33:54 2011] [error] Global symbol "$nosocks" requires explicit package name at (eval 244) line 35.
Global symbol "$lists" requires explicit package name at (eval 244) line 42.
Global symbol "$mydata" requires explicit package name at (eval 244) line 66.
Global symbol "$notask" requires explicit package name at (eval 244) line 107.
Global symbol "$tasks" requires explicit package name at (eval 244) line 112.
Global symbol "$tasks" requires explicit package name at (eval 244) line 114.
Global symbol "$tasks" requires explicit package name at (eval 244) line 115.
Global symbol "$tasks" requires explicit package name at (eval 244) line 116.
Global symbol "$tasks" requires explicit package name at (eval 244) line 116.
Global symbol "$tasks" requires explicit package name at (eval 244) line 118.
Global symbol "$tasks" requires explicit package name at (eval 244) line 127.
Global symbol "$tasks" requires explicit package name at (eval 244) line 130.
Global symbol "$nosocks" requires explicit package name at (eval 244) line 134.
Global symbol "$error" requires explicit package name at (eval 244) line 141.
Missing right curly or square bracket at (eval 244) line 151, at end of line
(eval 244) has too many errors.

./test.sh

This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking contiblem.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: nginx/0.9.3
Server Hostname: contiblem.net
Server Port: 80

Document Path: /login/
Document Length: 973 bytes

Concurrency Level: 100
Time taken for tests: 2.605 seconds
Complete requests: 1000
Failed requests: 47
(Connect: 0, Length: 47, Exceptions: 0)
Broken pipe errors: 0
Non-2xx responses: 47
Total transferred: 1123472 bytes
HTML transferred: 934001 bytes
Requests per second: 383.88 #/sec
Time per request: 260.50 ms
Time per request: 2.61 [ms](mean, across all concurrent requests)
Transfer rate: 431.28 [Kbytes/sec] received

Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 19 249 57.5 232 499
Waiting: 18 248 57.4 232 498
Total: 19 249 57.5 232 499
ERROR: The median and mean for the initial connection time are more than twice the standard
deviation apart. These results are NOT reliable.

Percentage of the requests served within a certain time (ms)
50% 232
66% 237
75% 243
80% 248
90% 305
95% 396
98% 457
99% 476
100% 499 (last request)

Part of the query produces a 404 ...

nginx.conf
...
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_headers on;
proxy_pass_request_body on;
proxy_intercept_errors on;
proxy_pass http://unix:/tmp/socketfarm.sock;
proxy_redirect default;
}

perl -v

This is perl 5, version 12, subversion 3 (v5.12.3) built for amd64-freebsd-thread-multi

Silently ignores when buffering request fails

Starman ignores errors while buffering the full request body.

When the TEMPDIR is full Plack::TempBuffer->print() would return 0 and set $! to ENOSPC. But this possible error is not catched by Starman. This means that the application will get a silently truncated body with the expectation that buffering succeeded.

Starman should either die (or better return with status code 413) or stop transparently buffering (which might be hard) when printing to the buffer fails.

Implement --disable-keepalive

to avoid issues with stupid frontend proxies like mod_proxy. We could probably do the same for all http-11 features as well?

Keep Alive causing flakey performance

I'm getting strange performance behaviour with Starman 0.1006.

Unfortunately my test case is "run this big complex webapp" so I'm not sure how useful this bug report is going to be.

Basically, on the new PSGI branch of WebGUI, I get stable ~300 req/sec when running under Starlet.
Performance is measured via: ab -t 5 -c 10 -k

Whereas when using Starman, I get anything from 1 req/sec to 30 req/sec. No errors or warnings that I can see, just crazy performance.

Tried --workers 1 but nothing changed.

Tried --disable-keepalive and problem immediately went away (getting stable ~370 req/sec).

To double-check that it wasn't a keepalive problem caused by WebGUI, I tried Starlet with --max-keepalive-reqs 100, but the reqs/sec didn't change.

Happy to help debug this, but not sure where to start.

Cheers,

Patrick

problem with FindBin

If you have a psgi application that uses the FindBin module starman seems to crash when restarting worker processes.

For example if I have a simple app.psgi like

#!/usr/bin/perl
use FindBin;
my $app = sub {
  my $env = shift;
  return [
      '200',
      [ 'Content-Type' => 'text/plain' ],
      [ "Hello World" ],
   ];
}

when I run it with starman -E development --max-requests=1 --workers=1 app.psgi
I just need to do one request make it crash. This what I see on my console:

starman -E development --max-requests=1 --workers=1 app.psgi 
2011/02/22-15:25:20 Starman::Server (type Net::Server::PreFork) starting! pid(3022)
Binding to TCP port 5000 on host *
Setting gid to "100 100 33 100"
Starman: Accepting connections at http://*:5000/
Error while loading app.psgi: Cannot find current script 'starman master -E development --max- requests=1 --workers=1 app.psgi' at /usr/lib/perl5/5.10.0/FindBin.pm line 206
BEGIN failed--compilation aborted at /usr/lib/perl5/5.10.0/FindBin.pm line 206, <_READ> line  2.
Compilation failed in require at app.psgi line 2, <_READ> line 2.
BEGIN failed--compilation aborted at app.psgi line 2, <_READ> line 2.
Error while loading app.psgi: Cannot find current script 'starman master -E development --max-requests=1 --workers=1 app.psgi' at /usr/lib/perl5/5.10.0/FindBin.pm line 206 
...

Maybe FindBin crashes because of the line
$0 = "starman worker " . join(" ", @{$self->{options}{argv} || []});
in Starman::Server::child_init_hook

Wrong "sysread" return code processing in Starman::Server::_read_headers

If we send empty request to starman, we'v got an error like this "Read error: ".
It's because of "|| $read == 0" section after syscall.
Empty request is not an error, it doesn't set $! variable.
Sysread manual:
..Returns the number of bytes actually read, 0 at end of file, or undef if there was an error (in the latter case $! is also set)...

eval {
    local $SIG{ALRM} = sub { die "Timed out\n"; };

    alarm( READ_TIMEOUT );

    while (1) {
        # Do we have a full header in the buffer?
        # This is before sysread so we don't read if we have a pipelined request
        # waiting in the buffer
        last if defined $self->{client}->{inputbuf} && $self->{client}->{inputbuf} =~ /$CRLF$CRLF/s;

        # If not, read some data
        my $read = sysread $self->{server}->{client}, my $buf, CHUNKSIZE;

        if ( !defined $read || $read == 0 ) {
            die "Read error: $!\n";
        }

        if ( DEBUG ) {
            warn "[$$] Read $read bytes: " . dump($buf) . "\n";
        }

        $self->{client}->{inputbuf} .= $buf;
    }
};

Using FindBin in the app croaks because of $0 change (was: Worker process can't find script (Mojolicious app script)

I start a mojolicious app (default mojolicious app) using starman:

$ starman script/app

And send request and receive Internal Server Error.

Error log:

Cannot find current script 'starman worker -I/tk/mojo/lib script/app' at /usr/lib/perl5/5.12.1/FindBin.pm line 205
BEGIN failed--compilation aborted at /usr/lib/perl5/5.12.1/FindBin.pm line 205.
Compilation failed in require at /tk/mojo/lib/Mojo/Home.pm line 12.
BEGIN failed--compilation aborted at /tk/mojo/lib/Mojo/Home.pm line 12.
Compilation failed in require at /tk/mojo/lib/Mojo.pm line 13.
BEGIN failed--compilation aborted at /tk/mojo/lib/Mojo.pm line 13.
Compilation failed in require at (eval 72) line 2.
...propagated at /usr/lib/perl5/5.12.1/base.pm line 94.
BEGIN failed--compilation aborted at /tk/mojo/lib/Mojolicious.pm line 8.
Compilation failed in require at (eval 71) line 2.
...propagated at /usr/lib/perl5/5.12.1/base.pm line 94.
BEGIN failed--compilation aborted at script/../lib/App.pm line 6.
Compilation failed in require at (eval 70) line 2.

But Mojolicious::Lite app works correctly.

And plackup works:

$ plackup script/app

Only starman fail.

Error log is spammed if app can't be loaded

If you're using delayed app loading (default) and a PSGI app can't be loaded, the error log is spammed with the following messages:

Error while loading /path/to/app.psgi: error message

This causes the log file to grow quickly even if there's no other activity on the server which can be pretty dangerous if it isn't detected soon enough.

The reason is that with delayed loading, the PSGI app is loaded in the child_init_hook where an uncaught exception causes the child to terminate. Another child is respawned immediately which will result in the same error message again and again.

I'd like to have the option to shut the whole server down in this case but I'm not sure if this is possible with Net::Server.

Another solution would be to catch exceptions in child_init_hook, log them once and let the child run. Then another error could be logged on every request which should result in much less log spam.

Display bug when combined with Server::Starter

reported by @timbunce

When you run starman with start_server with the development environment, it displays:

Starman: Accepting connections at http://*:5000/

when it's actually not listening on the port, which is wrong and confusing.

Pod::Usage isn't declared as a dependency on the right version

This is on Pod::Usage 1.16:

$ starman --help
Can't locate object method "initialize" via package "Pod::Usage" ...

Upgrading to 1.36 makes the problem go away, so the initialize method was added somewhere between 1.16..1.36.

Starman either needs to have a dependency on the latest version or whatever version introduced that API.

starman --listen decided as backlog queue by Net::Server inside

I believe that the option listen of starman (IP:PORT format for example) is decided by Net::Server inside as backlog option because the last looks in @argv as i think

From doc of Net::Server:

listen \d+ SOMAXCONN

I got messages in error.log of starman:

Argument "XX.XX.XX.XX:PPPP" isn't numeric in numeric gt (>) at /usr/local/lib/perl5/5.16.2/x86_64-linux-thread-multi/IO/Socket.pm line 224.

I looked in code, added 'carp' to $SIG{WARN} inside Socket.pm (224) and got:
Argument "XX.XX.XX.XX:PPPP" isn't numeric in numeric gt (>) at /usr/local/lib/perl5/5.16.2/x86_64-linux-thread-multi/IO/Socket.pm line 224.
at /usr/local/lib/perl5/site_perl/5.16.2/Net/Server.pm line 325

The submodule Net::Server::Proto::TCP has lines:

    $sock->NS_listen(defined($info->{'listen'}) ? $info->{'listen'}
                    : defined($server->{'server'}->{'listen'}) ? $server->{'server'}->{'listen'}
                    : Socket::SOMAXCONN());

I am sure that listen there as my IP:PORT

So when i run:

starman --listen IP:PORT --backlog 6000
I have backlog as 'IP:PORT' (may be first digit in my IP address)

Please check up this

Thanks

Perlover

shiny new ssl appears broken?

I am sorry for the lack of details, I am not able to share much and I fear this report will not be very useful. Miyagawa asked me to write it though

App: mod_perl/cgi app converted to plack using WrapCGI (not using execute flag)

  • App works fine when run via Plack::Handler::Apache2 in apache+mod_perl.
  • App works fine in non-ssl mode (requires hacking app to not require ssl)

When we enable starman's ssl we seem to have an issue where the page never fully loads.

  • How much of the page loads seems to be random.
  • Problem occurs on both the ssl and non-ssl ports.
  • The Debug middleware fails to inject itself into the page, works fine w/o the ssl

I am afraid I cannot share the app or configuration that produces this issue, and I have not created a small sample test case yet, if I manage to do it I will attach it. According to Miyagawa others have mentioned the same issue.

Sending HUP to a server started with --preload-app doesn't load code changes

To reproduce:

  • start starman with --preload-app
  • make a code change
  • send HUP to the starman master process, I see the log message:

Sending children hup signal during HUP on prefork server

but the new code doesn't seem to be loaded. If starman is started without --preload-app it works as expected.

Tested with version 0.3005

Very high CPU usage

I've deploy a dancer app on Starman (cpan version v0.2004).
But the cpu usage is very high! I must to nice it, otherwise it will grownup to 100%.
So, I switch to Plack and FCGI handler, it works fine.
My app is deployed on:

http://tu.chinavisual.com/

So, any suggest about the problem? How can I deal this?

BTW, I can't install with git version, it fatal:

include /usr/local/src/Starman/inc/Module/Install.pm
String found where operator expected at Makefile.PL line 9, near "readme_from 'lib/Starman.pm'"
(Do you need to predeclare readme_from?)
syntax error at Makefile.PL line 9, near "readme_from 'lib/Starman.pm'"
Bareword "auto_set_repository" not allowed while "strict subs" in use at Makefile.PL line 25.
Execution of Makefile.PL aborted due to compilation errors.

Starman(0.3007). Error at startup.

Plack version: 1.0020
Starman version: 0.3007
Perl version: v5.10.1
After Starman update(from 3.006 to 3.007) i've got error:
Error while loading development.pm: No such file or directory at (eval 7) line 4.
On 3.006 starman all works fine.
Starman starting comand:
/usr/local/bin/starman --user nginx --group nginx --error-log /var/log/starman/s_error.log --workers 5 -D -E development --pid /var/run/starman.pid -I/var/spool/app/lib --listen /var/run/starman.socket /var/spool/app/psgi/app.psgi >> /var/log/starman/starman.log
On another server without updates all fine.
Updated modules:
Starman
Plack
UPD: it seems, starman update OK. All works fine with Starman 0.3007 and Plack 1.0018.

Small test fail on FreeBSD 8.2, looking for localhost ip, got actual ip

This is a new FreeBSD VM, and I've just used perlbrew to install 5.14.2 locally...

FreeBSD 8.2-RELEASE FreeBSD 8.2-RELEASE #1

prove -lvr t/suite.t 
t/suite.t .. 2011/12/30-19:48:04 Starman::Server (type Net::Server::PreFork) starting! pid(77243)
Binding to TCP port 50026 on host 127.0.0.1
Setting gid to "1003 1003 1003"

not ok 46
#   Failed test at /home/lpm/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Plack/Test/Suite.pm line 248.
#          got: 'REQUEST_METHOD:GET
# SCRIPT_NAME:
# PATH_INFO:/foo/
# QUERY_STRING:dankogai=kogaidan
# SERVER_NAME:179.25.7.30
# SERVER_PORT:50026
# '
#     expected: 'REQUEST_METHOD:GET
# SCRIPT_NAME:
# PATH_INFO:/foo/
# QUERY_STRING:dankogai=kogaidan
# SERVER_NAME:127.0.0.1
# SERVER_PORT:50026

I didn't know how the box is configured (being a Debian person) but thought I'd report it, have just force installed :)

Support setting the process name

Starman::Server sets the process name to "starman master" and "starman worker". If multiple instances of starman run parallel on multiple ports this is confusing. It would help to be able to assign a process name to an instance of starman. How about a launcher option --name?

Document the use of FindBin

Because Starman mangles $0, using FindBin in the child process causes issues (actually crashes the process). Preloading FindBin with -MFindBin will avoid the crash but it will return $FindBin::Bin as the 'plackup' or 'starman' path, not the .psgi path.

You're suggested to use __FILE__ instead. And maybe we can think of a way to trick FindBin (or at least localize $0 when evaluating .psgi)

harakiri tests fails

On perl 5.14.0, CentOS 5.6 one of the harakiri test sometimes/mostly fails with:

#   Failed test 'In non-harakiri mode, pid is reused'
#   at /var/lib/hudson/jobs/combust/workspace/cpan/lib/perl5/Test/More.pm line 377.
#          got: '3'
#     expected: '5'

Starman-0.4006 - "Use of uninitialized value $opt in lc"

Hello,

Now i see a following warning (in terminal) when i start Starman process: Use of uninitialized value $opt in lc at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 70

When i had Starman version 0.4001 i got same error:

Use of uninitialized value $opt in lc at /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm line 69.

In previous versions i didn't see like these warnings

When streaming a response, calls to write() will hang if the connection has been lost.

Tell me if you can reproduce this. Here's a simple app that streams and infinite response. Notice that a warning is emitted to the server console after each write():

my $app = sub {

    return sub {
        my $responder = shift;
        my $headers = ['Content-Type' => 'text/plain'];
        my $writer  = $responder->( [200, $headers] );

        while (1) {
            $writer->write("SOME OUTPUT\n");
            warn "Wrote stuff\n";
        }
    };
}

Now launch that on a remote machine, using just one worker (and keep the console open so you can see the warnings).

starman --workers 1 app.psgi

From a different machine, hit the server (e.g):

curl http://remotehost:5000

After you start receiving the stream on localhost, abort the curl command by pressing Ctrl-C.

At this point, the next call to write() appears to block indefinitely, and the server does not emit any more warnings.

But if you do the same experiment using the same machine for both server and client, then write() does not block and the server continues to emit warnings.

I'm using a Mac and a Debian machine as my client & server (respectively). I suspect this has something to do with TCP/IP fundamentals more than it does Starman. So maybe you just need to educate me a bit here.

Endless retries to start the psgi app, instead of dying with errors.

Hi,
When I start my psgi app with starman and provide a wrong lib path (for example), starman keeps retrying (endlessly) to start my app while reporting the same error.

Is this a bug?

If not, how can I make Starman die immediately on (compile) errors?

(Starman version 0.4001).

Starman installs /usr/local/share/man/man3/.::Starman.3pm

[manu@orient Starman-0.3011]$ ./Build install --destdir /home/manu/tmp/foo
[..]
Installing /home/manu/tmp/foo/usr/local/share/man/man3/.::Starman.3pm
[...]

I'm not sure whether this comes from Starman or Module::Build::Tiny (0.018 was used here).

"commandline was not set during initialization" error with global __DIE__ signal handler

We have the following test application with global sigdie handler:

#!/usr/bin/perl

use Carp qw(cluck);
BEGIN {$SIG{__DIE__} = sub {cluck @_}};

my $app = sub {
  my $env = shift;
};

Starting it in common way:

starman --preload-app app.psgi

fires "commandline was not set during initialization" error

commandline was not set during initialization at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 103.
 at app.psgi line 9.
        Plack::Sandbox::app_2epsgi::__ANON__('commandline was not set during initialization at /usr/local/p...') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 103
        Net::Server::commandline('Starman::Server=HASH(0x14fa6c8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 92
        eval {...} called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 92
        Net::Server::_initialize('Starman::Server=HASH(0x14fa6c8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 50
        Net::Server::run('Starman::Server=HASH(0x14fa6c8)', 'port', 'ARRAY(0x1917740)', 'host', 'ARRAY(0x14e3348)', 'proto', 'ARRAY(0x1917770)', 'serialize', 'flock', ...) called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Starman/Server.pm line 67
        Starman::Server::run('Starman::Server=HASH(0x14fa6c8)', 'CODE(0x14e2e38)', 'HASH(0x14e30d8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Handler/Starman.pm line 18
        Plack::Handler::Starman::run('Plack::Handler::Starman=HASH(0x14e2c10)', 'CODE(0x14e2e38)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Loader.pm line 84
        Plack::Loader::run('Plack::Loader=HASH(0x14dd5a8)', 'Plack::Handler::Starman=HASH(0x14e2c10)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Runner.pm line 267
        Plack::Runner::run('Plack::Runner=HASH(0x130fdb0)') called at /usr/local/perl-5.14.2/bin/starman line 31
2012/11/08-15:38:31 Starman::Server (type Net::Server::PreFork) starting! pid(6272)
Address family not supported by protocol at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 133.
 at app.psgi line 9.
        Plack::Sandbox::app_2epsgi::__ANON__('Address family not supported by protocol at /usr/local/perl-5...') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 133
        eval {...} called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 133
        Net::Server::Proto::get_addr_info('Net::Server::Proto', '*', 5000, 'tcp') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 81
        eval {...} called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 81
        Net::Server::Proto::parse_info('Net::Server::Proto', 5000, '*', 'tcp', undef, 'Starman::Server=HASH(0x14fa6c8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 279
        Net::Server::port_info('Starman::Server=HASH(0x14fa6c8)', 5000, '*', 'tcp', undef) called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 264
        Net::Server::prepared_ports('Starman::Server=HASH(0x14fa6c8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 240
        Net::Server::pre_bind('Starman::Server=HASH(0x14fa6c8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server.pm line 55
        Net::Server::run('Starman::Server=HASH(0x14fa6c8)', 'port', 'ARRAY(0x1917740)', 'host', 'ARRAY(0x14e3348)', 'proto', 'ARRAY(0x1917770)', 'serialize', 'flock', ...) called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Starman/Server.pm line 67
        Starman::Server::run('Starman::Server=HASH(0x14fa6c8)', 'CODE(0x14e2e38)', 'HASH(0x14e30d8)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Handler/Starman.pm line 18
        Plack::Handler::Starman::run('Plack::Handler::Starman=HASH(0x14e2c10)', 'CODE(0x14e2e38)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Loader.pm line 84
        Plack::Loader::run('Plack::Loader=HASH(0x14dd5a8)', 'Plack::Handler::Starman=HASH(0x14e2c10)') called at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Plack/Runner.pm line 267
        Plack::Runner::run('Plack::Runner=HASH(0x130fdb0)') called at /usr/local/perl-5.14.2/bin/starman line 31
Resolved [*]:5000 to [0.0.0.0]:5000, IPv4
Host [*] resolved to IPv6 address [::] but IO::Socket::INET6->new fails: Address family not supported by protocol at /usr/local/perl-5.14.2/lib/site_perl/5.14.2/Net/Server/Proto.pm line 133.
Binding to TCP port 5000 on host 0.0.0.0 with IPv4
Setting gid to "30328 30328 30328 30489 30490"

Starman and timeout

Hello,

My situation is the following.
I use starman to serve a Perl Dancer API application. My main client timeout after 10 seconds. But the starman still run after if the request is really big (BigData project) then if a client call the API on the same server instance which still run then it doesn't answer.

Is there a way to set a time out on starman which stop the execution of Dancer request ?

Thank you
Nicolas

Crashing .psgi is not logged (with --preload-app)

Reproduction steps:

create app.psgi containing:

my $app = die 'this app cannot be created!';

then:

starman --preload-app --error-log error.log app.psgi

The error log does not capture any details about the death (indeed it is totally empty). It should be obvious in the log that the app crashed, but it is not.

I'm not sure if this is really an issue with Plack::Runner or Net::Server::* ? Just doing plackup app.psgi properly dumps the error to the console.

--Reload doesn't work with --daemonize

When running Starman with --Reload and --daemonize it isn't able to restart when a monitored file changes. It works fine when it isn't daemonized.

Output from error log (with --error_log flag)

Process Backgrounded
2011/12/16-15:43:41 Starman::Server (type Net::Server::PreFork) starting! pid(18558)
Using default listen value of 128
Binding to TCP port 5000 on host *
Setting gid to "33 33 33"
Process Backgrounded
2011/12/16-15:43:49 Starman::Server (type Net::Server::PreFork) starting! pid(18573)
Using default listen value of 128
Binding to TCP port 5000 on host *
2011/12/16-15:43:49 Can't connect to TCP port 5000 on * [Address already in use]
  at line 88 in file /usr/local/perls/perl-5.12.2/lib/site_perl/5.12.2/Net/Server/Proto/TCP.pm
2011/12/16-15:43:49 Server closing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.