in reply to How to fork in PSGI/Dancer2

My advice is that a web-service process, no matter how it is implemented, should not directly own nor control “a long-running child process.”   That is, in fact, a batch job, and it should be treated as such by a separate service-runner of some kind, perhaps using a database as a queue ... of which there are already many good examples and framework in CPAN and elsewhere.

The web service should then provide a user interface to this activity, enabling users to queue requests and to monitor the completion of their requests ... without waiting for them, or owning them itself.

I have seen strategies that are as simple as cron jobs which are launched, say, twice a minute.   I have seen batch-runners which are constructed just like web-servers (or rather, RPC = Remote Procedure Call servers), using the same “plumbing” that has already been developed for that purpose.   There are lots of ways to do it, but the principle remains:   the web service provides an interface to the batch process, but does not itself own the processes that are doing the work.