AW: AW: [IRCServices] Backup Feature?

Ian R. Justman ianj at esper.net
Thu Jan 25 00:30:31 PST 2001


On Mon, 22 Jan 2001, Strider wrote:

> I think the cron job idea is the best I've seen out of all of this. It uses
> the least amount of resources, has less overhead, and no database issues. A
> cron job that runs every 5 minutes would work great for that. All you would
> have to do is write a script that checks to see if services is running, and
> if it finds it isn't, start them up.

This is what I have running on the EsperNet :

========== 8< ============ Snipperoonie ==============

#!/usr/bin/perl

$pidfile = "$ENV{HOME}/lib/services.pid";
$services = "$ENV{HOME}/bin/services";

if ( ! -e "$pidfile" ) {
    system("$services");
    exit;
} else {
    $pid = `cat $pidfile`;
    chomp $pid;
    if ( ! -e "/proc/$pid" ) {
        system("rm $pidfile");
        system("$services");
        exit;
    }
    # If we got this far, assume that Services are running correctly,
    # then exit.
}

========== 8< ============ Snipperoonie ==============

Then season to taste.

On EsperNet, Services runs under its own UID and out of its own home
directory.  As-is (except for the values of $pidfile and $services, which
are site-specific, especially if you are not running this out of a "home
directory"), this should work just fine under Linux, FreeBSD, and perhaps
OpenBSD.  NetBSD uses /kern, if memory serves.  Otherwise, as always,
YMMV.

Hell, you could even run this every minute if you so chose since all it
really does is check for the presence of one "file" named with the
contents of another (assuming THAT file exists, then restarting Services
if not or if the one in /proc does not exist).

The only real sacrifice you might make here is the memory footprint of the
Perl interpreter when it starts.  I just found it annoyingly easy (and
enjoyable) to implement in Perl. :)

> One feature I'd like to see though that the cron job idea could benefit from
> is being able to send the process arguments and it work to where you can
> send a global from outside of the ircd. I could see this being useful for
> the script to send a global to all users with a warning to identify to
> nickserv and an apology about services being down. I could see other
> benefits from this as well later on down the line in conjuction with logs
> and tail -f if one didn't care to log into irc.

You could probably hack in @ARGV support or put in a file that the script
would then "include" or "require" into the code, passing those values to
Services when you fire up.  Or whichever method you'd prefer.

Perl rocks my world, what more can I say? :)

--Ian R. Justman, Co-Founder and Postmaster, The EsperNet IRC Network.

-----
Ian R. Justman (NIC handle IJ12)  ianj at esper.net (Official EsperNet business)
Co-Founder and Postmaster, The EsperNet IRC Network
Server Administrator, chocobo.esper.net "IJ" on IRC

PGP key available upon request, or finger ianj at esper.net.

If this message was signed with the Postmaster's key, please finger
postmaster at esper.net for the Postmaster public key.

Type Bits/KeyID    Date       User ID
pub  1024/BAB34B69 1997/11/15 EsperNet Postmaster <postmaster at esper.net>
            Key fingerprint = 05 BD 7C B5 8E 0B FD EF  EE 47 49 C4 96 11 59 75