2

I have a PSGI script using plack builder which is being executed using uwgsi by having multiple processes spawned. I have to refresh every minute an internal hash by using a database call. Is it somehow possible, independent from outside process/worker execution, to have some code lines being executed every given intervall?

  • See also [How can I tell Perl to run some code every 20 seconds?](https://stackoverflow.com/q/3749289/2173773) – Håkon Hægland Sep 08 '19 at 13:04
  • Thanks, but the PSGI is async. I need a "Cronjob" completely indepentent from outside async calls, no bottleneck - no user should wait 60 sec. until the inner cron code lines are executed and the users request is then executed afterwards.. – Benjamin Weiß Sep 08 '19 at 13:06
  • Can you use a daemon, e.g. [Proc::Daemon](https://metacpan.org/pod/Proc::Daemon) ? – Håkon Hægland Sep 08 '19 at 13:10
  • There is also a [uwsgi signal framework](https://uwsgi-docs.readthedocs.io/en/latest/Signals.html), maybe that can be used to set up a timer? – Håkon Hægland Sep 08 '19 at 13:17
  • No, that won't work, unfortunately. Uwsgi, twiggy, plackup etc. will handle all the processes and workers. I need an inner solution, maybe in sub builder {} or some inner callback? – Benjamin Weiß Sep 08 '19 at 13:20
  • 1
    I read that docu so many times and I didn't see that :) I did some tests by registering the signal and include a sub routine in the PSGI, I guess signal framework is the right solution. Great. Thanks a lot!!! – Benjamin Weiß Sep 08 '19 at 14:19
  • Could you write an answer of your own when you're done please? – simbabque Sep 09 '19 at 10:40

0 Answers0