[LON-CAPA-cvs] cvs: loncom / lonsql
raeburn
raeburn at source.lon-capa.org
Sun Jul 5 19:22:32 EDT 2026
raeburn Sun Jul 5 23:22:32 2026 EDT
Modified files:
/loncom lonsql
Log:
- When starting lonsql write entry in /home/httpd/html/lon-status/mysql.txt
if successful or unsuccessful, in format time=<timestamp>&mysql=<status>
where <status> is either defunct or ok.
Index: loncom/lonsql
diff -u loncom/lonsql:1.100 loncom/lonsql:1.101
--- loncom/lonsql:1.100 Thu Jul 31 15:47:25 2025
+++ loncom/lonsql Sun Jul 5 23:22:32 2026
@@ -3,7 +3,7 @@
# The LearningOnline Network
# lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
#
-# $Id: lonsql,v 1.100 2025/07/31 15:47:25 raeburn Exp $
+# $Id: lonsql,v 1.101 2026/07/05 23:22:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -227,6 +227,9 @@
# Make sure that database can be accessed
#
my $dbh;
+if (-e "$perlvar{'lonDocRoot'}/lon-status/mysql.txt") {
+ unlink("$perlvar{'lonDocRoot'}/lon-status/mysql.txt");
+}
unless ($dbh = DBI->connect("DBI:mysql:loncapa","www",
$perlvar{'lonSqlAccess'},
{ RaiseError =>0,PrintError=>0})) {
@@ -236,13 +239,17 @@
system("echo 'Cannot connect to MySQL database!' |".
" mail -s '$subj' $emailto > /dev/null");
- open(SMP,">$perlvar{'lonDocRoot'}/lon-status/mysql.txt");
- print SMP 'time='.time.'&mysql=defunct'."\n";
- close(SMP);
+ if (open(SMP,">$perlvar{'lonDocRoot'}/lon-status/mysql.txt")) {
+ print SMP 'time='.time.'&mysql=defunct'."\n";
+ close(SMP);
+ }
exit 1;
} else {
- unlink("$perlvar{'lonDocRoot'}/lon-status/mysql.txt");
+ if (open(SMP,">$perlvar{'lonDocRoot'}/lon-status/mysql.txt")) {
+ print SMP 'time='.time.'&mysql=ok'."\n";
+ close(SMP);
+ }
$dbh->disconnect;
}
More information about the LON-CAPA-cvs
mailing list