Application auto-restart?
Bill McGonigle
bill at bfccomputing.com
Mon Jan 30 09:37:01 EST 2006
On Jan 30, 2006, at 08:57, Drew Van Zandt wrote:
> Hi all...
> A while back I recall someone mentioning a script / application that
> watched a process and restarted the app if it crashed... I'm having a
> server
It probably wasn't mine, but you're welcome to it:
#!/usr/bin/perl -w
use Watchdog::Process;
use Sys::Load qw/uptime/;
use strict;
use warnings FATAL=>'all';
# This is application-watcher.pl
# It watches for the applicationd daemon to crash, and if it does
reboots the machine
# it won't reboot before 10 minutes of uptime to prevent thrashing
#
# Run it from root's crontab like:
# * * * * * /usr/local/sbin/application-watchdog.pl
#
# Copyright (c) 2005 BFC Computing, LLC <gpl at bfccomputing.com>
# Distributed under the terms of the GPL:
http://www.gnu.org/copyleft/gpl.html
my $VERSION = 0.01;
my $MINIMUM_UPTIME = 10*60; # seconds
my $SERVICE = 'applicationd';
my $PROCESS_STRING = '/usr/local/bin/applicationd -f
/usr/local/etc/applicationd.conf';
my $FAILURE_ACTION = "/sbin/reboot";
my $process = new Watchdog::Process($SERVICE,$PROCESS_STRING);
if (!$process->is_alive && (uptime() > $MINIMUM_UPTIME) ) {
system($FAILURE_ACTION);
}
-----
Bill McGonigle, Owner Work: 603.448.4440
BFC Computing, LLC Home: 603.448.1668
bill at bfccomputing.com Cell: 603.252.2606
http://www.bfccomputing.com/ Page: 603.442.1833
Blog: http://blog.bfccomputing.com/
VCard: http://bfccomputing.com/vcard/bill.vcf
More information about the gnhlug-discuss
mailing list