Question

I want to deploy a PSGI scripts that runs in Apache2 with Plack. Apache is configured with:

<Location "/mypath">
  SetHandler perl-script
  PerlResponseHandler Plack::Handler::Apache2
  PerlSetVar psgi_app  /path/to/my/script.psgi
</Location>

When I test the script with plackup, the --reload parameter watches updates on the .psgi file. In the production environment it is fine that Apache and Plack do not check and restart on each change for performance reasons, but how can I tell them explicitly to restart Plack::Handler::Apache2 and/or the PSGI script to deploy a new version?

It looks like Plack regularly checks for some changes but I have no clue when. Moreover it seems to create multiple instances, so I sometimes get different versions of script.psgi when at /mypath. It would be helpful to manually flush perl response handler without having to restart Apache or to wait for an unknown amount of time.

Was it helpful?

Solution

The short answer is you can't. That's why we recommend you to use plackup (with -r) for quick development and use Apache only for deployment (production use).

The other option is have a development apache process, and set MaxRequestsPerChild to a really small value, so that you will get a fresh child spawned in a very short period of time. I haven't tested this, and doing so will definitely impact the performance of your entire httpd, if you run the non-development application running on the same process (which is a bad idea in the first place anyway).

OTHER TIPS

Apache2::Reload (untested)

You can move your application out of the appache process, e.g.

FastCgiExternalServer /virtual/filename/fcgi -socket /path/to/my/socket

an run your programm with

plackup -s FCGI --listen /path/to/my/socket --nproc 10 /path/to/my/script.psgi

This way you can restart your application without restarting apache.

if you save the pid of the main fcgi process (--pid $pid_file) you can easyly restart an load your new code.

There is also a module avail to manage (start,stop, restart) all your fcgi pools: https://metacpan.org/pod/FCGI::Engine::Manager::Server::Plackup (not tested)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top