hello, i have this code:
var http = require('http')
, url = require('url')
, util = require('util')
, exec = require('child_process').exec;
var site = http.createClient(80, "www.domain.tld", false);
var req = site.request("GET", "/");
req.end();
req.on('response', function(res){
if(res.statusCode !== 200){
// launch a new instance
var ec2 = require("ec2")
, fs = require("fs");
// Read in the configuration above.
var configuration =
JSON.parse(fs.readFileSync("configuration.json", "utf8"));
// Create an ec2 function that uses your configuration.
ec2 = ec2(configuration)
// Run an instance and wait for it to become ready.
ec2("RunInstances", {
ImageId: "ami-XXXXXX"
, KeyName: "micros-ie"
, InstanceType: "t1.micro"
, MinCount: 1
, MaxCount: 1
}, function (error, response) {
if (error) {
throw error
}
ready();
});
} else {
res.on('data', function(chunk){
function puts(error, stdout, stderr) {
util.puts(stdout) }
exec("my command", puts);
});
}
});
basically, i would like to launch a new EC2 instance if the status
code is not equal to 200. this works ok, but my problem is that when
the code goes into the 'else' loop, i would like to check if the
'site' still returns a 200 status code.
any advice much appreciated
--
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