Skip to content

Commit

Permalink
added example for running code after a new Hypnotoad worker has been …
Browse files Browse the repository at this point in the history
…forked
  • Loading branch information
kraih committed Oct 24, 2012
1 parent 31315df commit f86cdd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

3.52 2012-10-24
3.52 2012-10-25
- Improved documentation.
- Improved tests.

3.51 2012-10-23
Expand Down
15 changes: 14 additions & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -78,7 +78,7 @@ for a full list see L<Mojo::Server::Hypnotoad/"SETTINGS">.

app->config(hypnotoad => {listen => ['http://*:3000']});

get '/' => {text => 'ALL GLORY TO THE HYPNOTOAD!'};
get '/' => {text => 'Hello Wor...ALL GLORY TO THE HYPNOTOAD!'};

app->start;

Expand All @@ -103,6 +103,19 @@ C<X-Forwarded-For> and C<X-Forwarded-HTTPS> headers.
# myapp.conf
{hypnotoad => {proxy => 1}};

Your application is preloaded in the manager process, and you can use
L<Mojo::IOLoop> timers to run code whenever a new worker has been forked.

use Mojolicious::Lite;

Mojo::IOLoop->timer(0 => sub {
app->log->info("Worker $$ star...ALL GLORY TO THE HYPNOTOAD!");
});

get '/' => {text => 'Hello Wor...ALL GLORY TO THE HYPNOTOAD!'};

app->start;

=head2 Nginx

One of the most popular setups these days is the built-in web server behind a
Expand Down

0 comments on commit f86cdd2

Please sign in to comment.