Hi,

is it possible to start a recurring timer only once when I have multiple 
workers?

So that I get this output

$ perl test.pl prefork -w 1
> [Thu Jul  3 11:29:09 2014] [info] Listening at "http://*:3000";.
> Server available at http://127.0.0.1:3000.
> [Thu Jul  3 11:29:09 2014] [info] Manager 1836 started.
> [Thu Jul  3 11:29:09 2014] [debug] Worker 1837 started.
> [Thu Jul  3 11:29:12 2014] [info] 0
> [Thu Jul  3 11:29:15 2014] [info] 1
> [Thu Jul  3 11:29:18 2014] [info] 2


instead of

$ perl test.pl prefork -w 4
> [Thu Jul  3 11:29:28 2014] [info] Listening at "http://*:3000";.
> Server available at http://127.0.0.1:3000.
> [Thu Jul  3 11:29:28 2014] [info] Manager 1838 started.
> [Thu Jul  3 11:29:28 2014] [debug] Worker 1839 started.
> [Thu Jul  3 11:29:28 2014] [debug] Worker 1840 started.
> [Thu Jul  3 11:29:28 2014] [debug] Worker 1841 started.
> [Thu Jul  3 11:29:28 2014] [debug] Worker 1842 started.
> [Thu Jul  3 11:29:31 2014] [info] 0
> [Thu Jul  3 11:29:32 2014] [info] 0
> [Thu Jul  3 11:29:32 2014] [info] 0
> [Thu Jul  3 11:29:32 2014] [info] 0
> [Thu Jul  3 11:29:34 2014] [info] 1
> [Thu Jul  3 11:29:35 2014] [info] 1
> [Thu Jul  3 11:29:35 2014] [info] 1
> [Thu Jul  3 11:29:35 2014] [info] 1
> [Thu Jul  3 11:29:37 2014] [info] 2
> [Thu Jul  3 11:29:38 2014] [info] 2
> [Thu Jul  3 11:29:38 2014] [info] 2
> [Thu Jul  3 11:29:38 2014] [info] 2


Code

use Mojolicious::Lite;

get '/' => sub {
    my $c = shift;
    $c->render(text => 'test');
};

sub start_recurring {
    my $i;

    Mojo::IOLoop->recurring(3 => sub {
      app->log->info($i++);
    });
}

start_recurring;

app->start;

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to