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.