Skip to content

Commit

Permalink
added example for listening on random port with Mojo::Server::Daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 29, 2014
1 parent 0424b5c commit e3b5881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -442,6 +442,10 @@ Run server.
Start accepting connections.
# Listen on random port
my $id = $daemon->listen(['http://127.0.0.1'])->start->acceptors->[0];
my $port = $daemon->ioloop->acceptor($id)->handle->sockport;
=head2 stop
$daemon = $daemon->stop;
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious.pm
Expand Up @@ -112,8 +112,7 @@ sub dispatch {
$plugins->emit_hook(before_routes => $c);
my $res = $tx->res;
return if $res->code;
my $err = $tx->req->error;
if ($err && (my $code = $err->{advice})) { $res->code($code) }
if (my $code = ($tx->req->error // {})->{advice}) { $res->code($code) }
elsif ($tx->is_websocket) { $res->code(426) }
$c->render_not_found unless $self->routes->dispatch($c) || $tx->res->code;
}
Expand Down

0 comments on commit e3b5881

Please sign in to comment.