Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Looking for a daemonizing module

by rjt (Curate)
on Sep 07, 2019 at 08:11 UTC ( #11105782=note: print w/replies, xml ) Need Help??

in reply to Looking for a daemonizing module

Any::Daemon seems alright, and Parallel::ForkManager might also be a reasonable choice for fork-model multiprocessing apps in Perl, even though it doesn't do a few of the things on your list.

From the synopsis:

use Parallel::ForkManager; $pm = Parallel::ForkManager->new($MAX_PROCESSES); foreach $data (@all_data) { # Forks and returns the pid for the child: my $pid = $pm->start and next; ... do some work with $data in the child process ... $pm->finish; # Terminates the child process }

I'm not sure how easy it will be to do an Apache-style graceful restart (your #3), as I haven't used P:FM in a while.

As for #4, that would be trivial to implement in the child itself. $pm->finish if ++$my_requests > $conf->{max_child_requests};

It doesn't give you any kind of PID file or command line help (Daemon::Control is nice for that, but it isn't really intended for multiprocessing), which is way harder to get right than a PID file.

I hope this helps. Without knowing more about your application, this advice is generic. Specific requirements might pull you in a different direction.

use strict; use warnings; omitted for brevity.

Replies are listed 'Best First'.
Re^2: Looking for a daemonizing module
by Dallaylaen (Chaplain) on Sep 10, 2019 at 13:17 UTC

    Parallel::ForkManager seems to do what I want. I knew about it, but somehow overlooked it in my search this time. Thank you.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105782]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-03-28 21:08 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (69 votes). Check out past polls.