Right Way to Fork in PSGI/Plac application (Perl)

489 views Asked by At

I have a such question - what is a right way to fork in PSGI/Plack application ?

On the one hand i know that PSGI app is "backend-agnostic", so it can be runned using different methods - FastCGI,CGI, etc But on the other hand i know that for example in FastCGI application we need to do some manipulation with FCGI::Request object before/after fork.

So what i must to do ?

  1. Just fork :)
  2. Do some magic manipulations and fork (What manipulations?)
  3. Rewrite application architecture => move all heavy operations into external daemon process.
1

There are 1 answers

8
Len Jaffe On

Since PSGI is a specification, you can use it in all of those situations. If you can run a PSGI app in mod_perl, with a FastCGIs server, as CGI, or youc an run onw of the native PSGI servers like plack etc.

How you start them obviously depends on which one you choose. Mod_perl lives and dies by its apache process, CGI scripts do not to be externally started. But FastCGI and the stand-alone PSGI servers like Starman tend to be handled by the reverse proxy, or started and stopped by hand. Leaving it up to the proxy, and the PSGI server's configuration is easiest, although sometimes you'll want to be able ot control the external processes independently of the proxy.