Hi,
<newbie alert>
i wrote a reverse web proxy with client-side X.509 cert authentication and
it has been working fine for months. The proxying is done by the
battle-hardened and popular http-proxy module. Since it is a proxy, the
HTTPS requests eventually arrive at a destination server. Now i would like
to add a check to "probe" the "liveness" of the destination server by
making a simple HTTP request every 5 seconds (approximately, of course) and
see if i get the 200 status code or something like that. If the
destination server is "dead" (not responding, etc.), further requests will
be proxied to a fail-over server (this is only for the near term -
eventually i will replace that with ZooKeeper discovery)
i was wondering what the best way is to architect the control-flow of
similar programs. The skeleton of my program currently is quite simple
since the bulk of the work is done by the http-proxy module:
================================================================
...
var
HTTPSproxyHost = '....com',
HTTPSproxyPort = 8888,
destHost = '....com',
destPort = 9999;
var proxyOptions = {
key: fs.readFileSync('...'),
cert: fs.readFileSync('...'),
...
};
var proxy = new httpProxy.HttpProxy({target: {host:destHost,
port:destPort}});
https.createServer (
proxyOptions,
function (req, res) {
...
proxy.proxyRequest(req,res);
}
}.listen(HTTPSproxyPort,HTTPSproxyHost);
================================================================
What should the program look like with proxying and at the same time
probing the liveness of the destination server? Are there any best
practices or cookbook recipes?
Can i simply resort to setTimeout and provide a named function as the
callback as follows:
================================================================
var PROBE_INTERVAL_MS = 5000;
setTimeout(
function probe() {
console.log('probing ...');
setTimeout(probe,PROBE_INTERVAL_MS);
},
PROBE_INTERVAL_MS
);
================================================================
Or i should use async.parallel + setTimeout, fibers + future, or some other
goodies? If so, what is the outline of the pertinent code snippet?
Thanks.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.