OK, so an update here. I have removed the fork() stuff. The problem is that when I create an object in my webapp, it goes out of scope immediately as the webapp is presented with plackup. Here's a much trimmed down repro example:

# Scope.pm in webapp root dir package Scope; sub new { return bless {}, shift } sub DESTROY { print "going out of scope...\n"; } # webapp package MyApp; use lib '.'; use Scope; use Dancer2; use Dancer2::Plugin::Database; our $VERSION = '0.1'; my $obj = Scope->new;

Now run it:

plackup -R lib,bin bin/app.pl

Here's what happens when I run it:

Watching lib bin bin/lib bin/app.pl for file updates. going out of scope HTTP::Server::PSGI: Accepting connections at http://0:5000/

I've also asked for guidance on the #dancer IRC channel. I'm hoping someone with experience with Dancer2 (or perhaps web frameworks in general) can help me get a grasp on getting around this issue (as I pour through resources I'm finding online elsewhere).


In reply to Re: Async timed events with Dancer2 by stevieb
in thread [SOLVED]: Async timed events with Dancer2 by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.