[dancer-users] How can a fork+system() Dancer app not create zombie processes?

Andrew Beverley andy at andybev.com
Thu Jun 29 07:32:52 BST 2017


On Thu, 29 Jun 2017 15:55:59 +1000 Nathan Bailey wrote:
> Hi all,
>    I want to send my Dancer2 TT page as an email *and* continue to generate
> a normal web response.
> 
> This forking discussion seems like an excellent approach.

I'm not convinced - it seems like overkill to me.

> An additional benefit of this approach is that the email is sent
> asynchronously, since Gmail-dispatched emails seem to take 2-3s to send.

I would initially investigate on why emails are taking so long to send.
Can you deliver the email locally instead? That should happen with very
little noticeable delay. It's then effectively asynchronous, as the
local mailer will be attempting to send the email whilst the web
application continues to run.

> This all works well and I am grateful for this discussion and Andy's
> example code, but I am unclear about the guard, per below.
> I understand what it is intended to do, but if I put:
>    my $guard = guard { info "I'm dying"; POSIX::_exit(0); };
> in my code, the code immediately prints the "I'm dying" and exits.

Have you loaded a suitable guard module (e.g. Guard or Scope::Guard)?
Otherwise (from memory) the application will exit before it raises an
exception of the missing guard function.

Andy


More information about the dancer-users mailing list