My CGI script accesses a mysql database, and it won't work in mysqld.exe isn't running. Sometimes, that program gets is shut down for various reasons. In my script, I have it script die if it can't connect to the database, and then I set $SIG{__DIE__} to exec mysqld.exe as the last thing it does.
When the script dies because the database connection didn't work, mysqld.exe is started as I want. However, I also want it to display a message in the browser indicating that refreshing your screen will fix the problem (because this time mysqld.exe will be running). However, my script just keeps running and eventually times out without showing any output. As I said, though, the exec is done successfully.
When the script dies because the database connection didn't work, mysqld.exe is started as I want. However, I also want it to display a message in the browser indicating that refreshing your screen will fix the problem (because this time mysqld.exe will be running). However, my script just keeps running and eventually times out without showing any output. As I said, though, the exec is done successfully.
Code:
$| = 1;
$SIG{__DIE__} = sub {
print "Content-type: text/html\n\n $_[0]";
exec 'C:\apache\mysql\bin\mysqld.exe' if $_[0]=~ /MySQL/;
};
my $DatabaseConnection = DBI->connect('dbi:mysql:lotto649') or die "MySQL Connection Failed. Please use your refresh button and everything should work normally. $!";