Discussion:
What about an after_server_start hook?
(too old to reply)
Stefan Adams
2018-11-23 23:24:11 UTC
Permalink
Sometimes it would be nice to have an event / hook for after the server has
started. Specifically, I'd want to kick off an automated process with
Mojo::IOLoop->timer|recurring but only after the web server has started.

Is this possible? And if not, is it a Pull Request that would be
considered?
--
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 ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Dan Book
2018-11-24 02:04:28 UTC
Permalink
You can set up code to be run whenever the ioloop is started, which happens
in each worker process when it starts in a prefork server, by adding a
next_tick callback as indicated here:
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Pre-forking

-Dan
Post by Stefan Adams
Sometimes it would be nice to have an event / hook for after the server
has started. Specifically, I'd want to kick off an automated process with
Mojo::IOLoop->timer|recurring but only after the web server has started.
Is this possible? And if not, is it a Pull Request that would be
considered?
--
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
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Stefan Adams
2018-11-24 02:10:46 UTC
Permalink
Ah! How cool! Thank you for that! That's gives me better context now for
understanding the purpose and value of next_tick. :)
Post by Dan Book
You can set up code to be run whenever the ioloop is started, which
happens in each worker process when it starts in a prefork server, by
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Pre-forking
-Dan
Post by Stefan Adams
Sometimes it would be nice to have an event / hook for after the server
has started. Specifically, I'd want to kick off an automated process with
Mojo::IOLoop->timer|recurring but only after the web server has started.
Is this possible? And if not, is it a Pull Request that would be
considered?
--
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
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
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Stefan Adams
2018-11-24 02:13:42 UTC
Permalink
Ah, shoot. That kicks off for every worker process. Any way to do
something where it runs just in the manager process?
Post by Stefan Adams
Ah! How cool! Thank you for that! That's gives me better context now
for understanding the purpose and value of next_tick. :)
Post by Dan Book
You can set up code to be run whenever the ioloop is started, which
happens in each worker process when it starts in a prefork server, by
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Pre-forking
-Dan
Post by Stefan Adams
Sometimes it would be nice to have an event / hook for after the server
has started. Specifically, I'd want to kick off an automated process with
Mojo::IOLoop->timer|recurring but only after the web server has started.
Is this possible? And if not, is it a Pull Request that would be
considered?
--
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
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
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Stefan Adams
2018-11-24 02:17:04 UTC
Permalink
"During startup your application is preloaded in the manager process, which
does not run an event loop"

So it looks like what I was hoping for is not possible. :(
Post by Stefan Adams
Ah, shoot. That kicks off for every worker process. Any way to do
something where it runs just in the manager process?
Post by Stefan Adams
Ah! How cool! Thank you for that! That's gives me better context now
for understanding the purpose and value of next_tick. :)
Post by Dan Book
You can set up code to be run whenever the ioloop is started, which
happens in each worker process when it starts in a prefork server, by
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Pre-forking
-Dan
Post by Stefan Adams
Sometimes it would be nice to have an event / hook for after the server
has started. Specifically, I'd want to kick off an automated process with
Mojo::IOLoop->timer|recurring but only after the web server has started.
Is this possible? And if not, is it a Pull Request that would be
considered?
--
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
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
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...