Le 23/10/2015 12:22, Jan Henning Thorsen a écrit :
> If it's not critical that changes in the file is visible instantly, you
> could do something like this:
It's not critical if the changes appears after a few seconds, so the
idea is good, thank you -- and thanks for the code, which is helpful.
> This will make the application read the file every 30 second and update
> the "dashboard" config parameter. The code could also check if the
> timestamp of the json file has changed and simply not read the content
> if mtime is the same.
I didn't like the idea of checking a mtime each time I did a request to
the data -- which would be almost each time a user displays a page.
Feels like loosing the efficiency of having everything in memory.
> Another idea is to use AnyEvent::Filesys::Notify instead of the
> recurring timer. (There might be similar solutions, but that was the one
> that came to mind first)
Oh, I didn't know of that one. And really like it, for it respects the
data/file paradigm for understandability.
It may indeed be the best solution, among other things for portability.
I will give it a try, and report back to the list next week.
Really good advice, thanks!
> About hot reloading: If you are running both the workers and manager as
> the same user, then the worker can do initiate hot reload using "kill
> USR2 => getppid".
Yes, smart! Still GTK (Good To Know (tm)).
Thanks again,
--
Boris
>> =MyApp::Model::Config->new($app)});
>> |
>> This doesn't resolve the issue.
>>
>> Then I read about similar problems with db connection
>> handles, and I decided to move them out of the startup
>> method and I added some has attributes, still in the
>> MyApp.pl class:
>> |
>> has my_config =>sub{state $config
>> =MyApp::Model::Config->new($app);};
>> |
>> But it still doesn't work.
>>
>> So, how should I do that? Any advice on the design or
>> code itself is welcome...
>>
>> Thanks in advance,
>>
>> --
>> Boris
>> --
>> 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
>>
mojolicious...@googlegroups.com.
>> To post to this group, send email to
>>
mojol...@googlegroups.com.
>> Visit this group at
>>
http://groups.google.com/group/mojolicious
>> <
http://groups.google.com/group/mojolicious>.
>> <
https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Mojolicious" group.
> To unsubscribe from this topic, visit
>
https://groups.google.com/d/topic/mojolicious/T9uH9a14CHM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
>
mojolicious...@googlegroups.com
> <mailto:
mojolicious...@googlegroups.com>.
> <mailto:
mojol...@googlegroups.com>.