node.js code implementation
€30-250 EUR
Paiement à la livraison
I have this code:
var http = require('http')
, url = require('url')
, util = require('util')
, exec = require('child_process').exec;
var site = [login to view URL](80, "[login to view URL]", false);
var req = [login to view URL]("GET", "/");
[login to view URL]();
[login to view URL]('response', function(res){
if([login to view URL] !== 200){
// launch a new instance
var ec2 = require("ec2")
, fs = require("fs");
// Read in the configuration above.
var configuration =
[login to view URL]([login to view URL]("[login to view URL]", "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: "[login to view URL]"
, MinCount: 1
, MaxCount: 1
}, function (error, response) {
if (error) {
throw error
}
ready();
});
} else {
[login to view URL]('data', function(chunk){
function puts(error, stdout, stderr) { [login to view URL](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.
So, i need this to be put into a function and then use recursion.
Also, the output of the exec("my command", puts); needs to be fed into a redis database.
Nº du projet : #1564347
À propos du projet
5 freelances font une offre moyenne de 88 € pour ce travail
We have an expert team for javascript and database handling.... Please provide a chance to work with you. Hope for good response.
Not much experience with node as well as handling EC2 instances but what you require seems simple enough to increase my node-foo. Please pick while keeping in mind the aforementioned factor. :)