Back to the month index |
Back to the list index
|
rasmus@madhaus.utcs.utoronto.ca
Sat, 7 Sep 1996 09:51:03 -0400 (EDT)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: CTM: "[mSQL] compile msql tcl in LInux?"
- Previous message: Gary Bickford: "[mSQL] php & msql project nearly done!"
- Next in thread: Guido A.J. Stevens: "[mSQL] Re: [PHP] 2 simple questions"
- Reply: Guido A.J. Stevens: "[mSQL] Re: [PHP] 2 simple questions"
From: rasmus@madhaus.utcs.utoronto.ca Date: Sat, 7 Sep 1996 09:51:03 -0400 (EDT) Subject: [mSQL] Re: 2 simple questions Message-Id: <ML-2.3.842104263.7349.rasmus@krone.house.mil>> 2) Had anyone written some kind of "is-msqld-alive" function ?
I run my msqld processes from init so if they die, init automatically
kicks them back up. This is what I have in my /etc/inittab
m1:234:respawn:/opt/msql/bin/msqld1
m2:234:respawn:/opt/msql/bin/msqld2
I have hacked up my version of mSQL to allow me to run multiple daemons
out of the same top-level /opt/msql directory.
Running it out of inittab fixes the problem of bringing the daemons back up
when they die, but there is some other weird state they can get into where
they simply stop answering queries. I have the following cron job to test
for this every 5 minutes:
#!/opt/gnu/bin/perl
use Msql;
$mailees = "net-eng\@madhaus.utcs.utoronto.ca";
$ENV{'MSQL_UNIX_PORT'} = "/dev/msql1";
$dbsock = Connect Msql;
if ( !$dbsock ) {
$sub = "msqld1 is stuck. Restarting it... \n";
if ( $verbose ) {
print "$sub";
}
&mail_it ("$mailees", "$sub", "");
system "/etc/init.d/msql kill 1";
} else {
if ( $verbose ) {
print "mSQL Daemon 1 is running\n";
}
}
undef($dbsock);
$ENV{'MSQL_UNIX_PORT'} = "/dev/msql2";
$dbsock = Connect Msql;
if ( !$dbsock ) {
$sub = "msqld2 is stuck. Restarting it... \n";
if ( $verbose ) {
print "$sub";
}
&mail_it ("$mailees", "$sub", "");
system "/etc/init.d/msql kill 2";
} else {
if ( $verbose ) {
print "mSQL Daemon 2 is running\n";
}
}
undef($dbsock);
sub mail_it {
my ($recipient, $subject, $msg) = @_;
my $mailer = "/usr/bin/mailx";
open(MAIL, "|$mailer -s \'$subject\' $recipient");
print MAIL $msg;
close MAIL;
}
The above script is obviously using msqlPerl. You could easily do it in
PHP as well. And, chances are you only have 1 daemon to check, so you
could simplify it quite a bit. Note that all I do to restart my daemons
is to kill them off. Since they are running under init, they will be
automatically respawned.
-Rasmus
--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!
- Next message: CTM: "[mSQL] compile msql tcl in LInux?"
- Previous message: Gary Bickford: "[mSQL] php & msql project nearly done!"
- Next in thread: Guido A.J. Stevens: "[mSQL] Re: [PHP] 2 simple questions"
- Reply: Guido A.J. Stevens: "[mSQL] Re: [PHP] 2 simple questions"