Instead of running "./webrestart", I'd likely be tempted to do that in perl directly, especially so I could get a small delay between the pkills and the pkill -9's (say, a half-second, which not all 'sleep' commands can do) to give fastcgi time to close down cleanly before being brutally virtually murdered ;-)

Also, I'm thinking that "pkill fcgi" is going to also kill fcgi-pm - after all, pkill is just grepping through the process list, and "fcgi" will match against "fcgi-pm" too. This leaves me with:

use Time::HiRes qw(usleep); use File::Spec; # this should be near, if not combined with, the @urls list to encoura +ge keeping them in sync # which is far better than doing this in a separate file! # (you may be able to even just use the @urls array to generate this l +ist, even better!) my @sites = qw( /path/to/site/one /path/to/other/site ); sub fastcgi_restart { system qw(pkill fcgi); usleep(500); system qw(pkill -9 fcgi); for (@sites) { # probably should pick a unique name for the socket somehow, but I +'ll leave that # to you - I'm just copying your code here. system File::Spec->catfile($_, 'fastcgi.pl'), qw(-l /tmp/mysite.so +cket -n 3 -d); } }
Though, to be honest, I'd probably create an init script for this in my /etc/init.d, yes, probably in shell, and then just call /etc/init.d/fastcgi restart instead.

Really cool, of course, would be to write an init script in perl that actually read your lighttpd configuration to determine the URLs and paths completely automatically, and could check the status, start, stop, and restart the fastcgi stuff. Then I'd have a cron job like this:

#!/bin/sh if ! /etc/init.d/lighttpd status > /dev/null; then /etc/init.d/lighttpd status fi if ! /etc/init.d/fastcgi status > /dev/null; then /etc/init.d/fastcgi restart fi
(This assumed that lighttpd's status worked the way you want/need, i.e., intutitively.)

Just my two cents. :-)

PS: ++ for trying to get your computer to do your work for you :-) It's a perfect example of Laziness.


In reply to Re: Keep FastCGI Processes Up and Running by Tanktalus
in thread Keep FastCGI Processes Up and Running by SouthFulcrum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.