Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Dancer2 start/stop hooks

by morgon (Priest)
on May 18, 2018 at 14:37 UTC ( [id://1214852]=perlquestion: print w/replies, xml ) Need Help??

morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

is there any hook or callback that would allow one to trigger some action whenever dancer starts and stops?

I have a very simple app that runs on my tablet and that I start whenever I need it and stop when I am finished.

It does not write any logs but I want to track the time I use it, so I would use these hooks to write timestamps to a file.

Many thanks!

Replies are listed 'Best First'.
Re: Dancer2 start/stop hooks
by stevieb (Canon) on May 18, 2018 at 15:42 UTC

    I don't know about hooks, but your app could perhaps utilize a BEGIN{} and END{} block to log such times. The former will log during compile (ie. startup), and the latter will log after the program has finished and just before exit.

      Yes, I've been thinking about that and it would probably work for my case, but in the general case (I think) a dancer app may fork several workers and that would result in serval END-blocks being fired for one run of dancer.

        You could get the PID in the script before you dance; and use it as a conditional in the END block.


        The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1214852]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found