The cron won't help. The problem is that the connections are spread into the webserver childs, and when an http request comes in (from a client or the cron job) it is handled by a (more or less) random child. No way to make sure every child gets an request every 5 minutes.
What happens if the connection times out? The server closes it and is happy, or does the backend server have any problems with it? And, is there any kind of "ping" message the perl wrapper could send to test if the connection is still alive?
I would just let the connections time out and don't care. If a perl wrapper finds the connection dead, it just silently opens a new one.
# $conn ||= connect();
if (not $conn or is_dead($conn) {
$conn = connect();
}
my $status = send($conn, 'abc');
if ($status == CONN_DEAD) {
$conn = connect();
$status = send($conn, 'abc');
}
| [reply] [d/l] |
What happens if the connection times out? The server closes it and is happy, or does the backend server have any problems with it?
No, thinking about it, the backend system should just happily close the connection. There should be no negative consequences of closing the connection beyond the fact that the next request will have to wait for it to re-establish (but we are talking about LAN-connected systems here, so I don't think that latency should be a big problem).
And, is there any kind of "ping" message the perl wrapper could send to test if the connection is still alive?
Yeah, you can send a "K0006" keep-alive message, in which case the server should respond likewise with a "K0006" response. This could serve as a "ping" I suppose. However, I may as well just see if the socket is dead, as you show in your example.
I'm busy trawling throught the mod_perl API docs again at the moment... hopefully I'll be making a start on this soon. Thanks again for your support.
Cheers, -- Dave :-)
$q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print
| [reply] |