Skip to content

Commit

Permalink
added low level event error logging recipe to cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 15, 2012
1 parent 527cba9 commit 3433bdf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -396,7 +396,7 @@ captured.
The maximum number of connections this loop is allowed to accept before
shutting down gracefully without interrupting existing connections, defaults
to C<0>. Setting the value to C<0> will allow this loop to accept new
connections infinitely. Note that this attribute is EXPERIMENTAL and might
connections indefinitely. Note that this attribute is EXPERIMENTAL and might
change without warning!
=head2 C<max_connections>
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -496,7 +496,7 @@ L<Mojolicious::Guides::Cookbook/"Hypnotoad"> for examples.
Maximum number of connections a worker is allowed to accept before stopping
gracefully, defaults to C<1000>. Setting the value to C<0> will allow workers
to accept new connections infinitely.
to accept new connections indefinitely.
=head2 C<backlog>
Expand Down
10 changes: 10 additions & 0 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -391,6 +391,16 @@ created at startup time.

app->start;

Since timers and other low level event watchers are also independent from
applications, errors can't get logged automatically, you can change that by
subscribing to the event L<Mojo::IOWatcher/"error">.

# Forward error messages to the application log
Mojo::IOLoop->singleton->iowatcher->on(error => sub {
my ($watcher, $err) = @_;
app->log->error($err);
});

Just remember that all events are processed cooperatively, so your callbacks
shouldn't block for too long.

Expand Down

0 comments on commit 3433bdf

Please sign in to comment.