http://www.perlmonks.org?node_id=525843

v01d has asked for the wisdom of the Perl Monks concerning the following question:

I've been investigating FastCGI to implement some functionality at my web site. I noticed that to start trying out my code in progress I have to reload Apache (apachectl restart) so the process running the FastCGI script dies and lets me spawn it again.

I can't find any other method to avoid reloading apache (because if the server is in use I don't wan't to restart it while someone is downloading something and cut him/her off). Is there any way to make that perl process reload the script cleanly (no hacks, I mean)? Maybe there's a way to configure mod_fastcgi to reload the script when it notices that the original code changed, but I can't find anything like that.

Replies are listed 'Best First'.
Re: FastCGI script reloading
by brian_d_foy (Abbot) on Jan 27, 2006 at 01:57 UTC

    Have you considered setting up a local web server and testing your stuff there? You can hack away and mess things up as much as you like without bothering anyone. :)

    Otherwise, I think you want the FastCGI FAQ that seems to answer this question.

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review

      I'm my own hosting space, so my Apache is on this computer =b. Regarding the FAQ: I already read that and when I read that specific entry I misunderstood it (I thought that mod_fastcgi could autoupdate itself =b).

      Ignore my stupidity and thanks for the reply.

Re: FastCGI script reloading
by Thilosophy (Curate) on Jan 27, 2006 at 07:18 UTC

    First off, why don't you develop using plain CGI and once the code is done, move over to FastCGI ? That way you dont need to restart all the time.

    That being said:

    killall my_program.fcgi
    In the usual setup, Apache spawns and controls the FastCGI instances. If one of them dies, it should automatically start a new one. So if you change your code, you could just kill the FastCGI process (rather than the whole Apache) and things get reloaded.
    apachectl graceful
    A graceful restart will not cut off currently connected users (not 100% sure if it restarts the FastCGI servers, though).

      Interesting options, I will try them