There are many options for synchronizing data between workers. The most common is to use a database, but you can also use realtime methods like pubsub over redis, postgres, or Mercury. -Dan
On Fri, Feb 23, 2018 at 7:24 AM, Michael Fung <[email protected]> wrote: > Many thanks, Dan. I am sorry I did not read the docs thoroughly enough. > > BTW, I wonder how the others do to synchronize secrets(or whatever data) > between workers. My current code still leave a small time window for > workers to be out of sync when they refresh the secrets. I use the secrets > for JWT sign/encrypt stuff, for security they are refreshed every n hours > by a housekeeper script... and I don't want to get the secrets from Redis > cache every time I use them. > > Any hints will be much appreciated. > > Rgds, > Michael > > > On Friday, February 23, 2018 at 4:18:32 PM UTC+8, Dan Book wrote: >> >> The startup method is run in the manager process before any forking. If >> you want something to occur in each worker, you can run it in a >> Mojo::IOLoop->next_tick callback. However note that this will also run in >> each worker that is started later, to replace workers that reach their >> max_accepts or stop responding. >> -Dan >> >> On Fri, Feb 23, 2018 at 2:48 AM, Michael Fung <[email protected]> wrote: >> >>> Hi All, >>> >>> I run my app like: >>> >>> ./script/web_api prefork -w 4 -c 100 -l "http://[::]:8808" >>> >>> In the startup section, I run a recurring timer and log an entry to the >>> log file. However, the '*web api started*' log entry does not repeat 4 >>> times. >>> >>> >>> $log->info('web api started'); >>> >>> Mojo::IOLoop->recurring(60 => sub { >>> $log->info($$.' - do refresh_secrets'); >>> $refresh_secrets->(); >>> }); >>> >>> >>> Log excerpt: >>> >>> [Fri Feb 23 15:19:22 2018] [info] web api started >>> [Fri Feb 23 15:20:22 2018] [info] 9471 - do refresh_secrets >>> [Fri Feb 23 15:20:22 2018] [info] 9468 - do refresh_secrets >>> [Fri Feb 23 15:20:22 2018] [info] 9469 - do refresh_secrets >>> [Fri Feb 23 15:20:22 2018] [info] 9470 - do refresh_secrets >>> >>> >>> Am I doing something wrong? >>> >>> >>> -- >>> 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 https://groups.google.com/group/mojolicious. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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 https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- 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 https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
