For the last several years, I’ve been using a setup of NGINX as a reverse proxy that passes any dynamic content requests to Apache. Apache then uses mod_fcgid to autospawn FastCGI-enabled Perl scripts into listener processes. For complex Perl code this has been a huge benefit, keeping database connections going, etc.
I’m now trying to go with a pure NGINX setup that skips Apache, however, I cannot figure out how to achieve the same basic autospawning functionality. It seems like most FCGI discussions regarding NGINX assume one manually launches a daemon specific to the script in question. It either runs one instance of the Perl script or, with multiwatch can manage multiple copies for a greater number of requests (as mod_fcgid does), but the simple fact remains that one must anticipate which FastCGI enabled Perl scripts are going to be run, have them waiting on a socket and then tell NGINX specifically about that script.
If one is hosting multiple virtual servers and each one has scripts that might need to be loaded, this is much more complex than simply letting mod_fcgid spawn those scripts and respawn them if they die.
Is there a way to achieve a mod_fcgid-like arrangement, which auto spawns as fcgiwrap can do, but unlike fcgiwrap, is for FastCGI enabled scripts that should persist between requests? (Since fcgiwrap is a legacy CGI wrapper, it just runs the script once per request, rather than giving the true benefit of FastCGI.)