Ditutup

[url removed, login to view] code implementation

I have this code:

var http = require('http')

, url = require('url')

, util = require('util')

, exec = require('child_process').exec;

var site = [url removed, login to view](80, "[url removed, login to view]", false);

var req = [url removed, login to view]("GET", "/");

[url removed, login to view]();

[url removed, login to view]('response', function(res){

if([url removed, login to view] !== 200){

// launch a new instance

var ec2 = require("ec2")

, fs = require("fs");

// Read in the configuration above.

var configuration =

[url removed, login to view]([url removed, login to view]("[url removed, login to view]", "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: "[url removed, login to view]"

, MinCount: 1

, MaxCount: 1

}, function (error, response) {

if (error) {

throw error

}

ready();

});

} else {

[url removed, login to view]('data', function(chunk){

function puts(error, stdout, stderr) { [url removed, login to view](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.

Kemahiran: Javascript, node.js

Lihat lebih lanjut: redis node, redis get, recursion problem, recursion function, javascript redis get, code get, redis nodejs, if js, redis, nodejs, micros, javascript nodejs, create js, code check, status code, javascript function response, json request response, loop json, node javascript, code check javascript, ec2 500, json response, code function, ec2 implementation, code status

Tentang Majikan:
( 7 ulasan ) nimes, United Kingdom

ID Projek: #1564347

7 pekerja bebas membida secara purata €84 untuk pekerjaan ini

solutionswithus

We have an expert team for javascript and database handling.... Please provide a chance to work with you. Hope for good response.

€130 EUR dalam 3 hari
(2 Ulasan)
5.6
bratushka

wrapping what needed in a recursive function is not a problem. but are you sure you really need recursion here, not a 'while' loop? i have no working experience with redis, but its docs and docs for its node.js driv Lagi

€70 EUR dalam 2 hari
(3 Ulasan)
3.1
guiqul

I can help you, sir.

€80 EUR dalam 3 hari
(4 Ulasan)
3.1
jeffmarketing

PLEASE CHECK PMB

€150 EUR dalam 3 hari
(0 Ulasan)
0.0
DarkSomething

I have great easperience working with nodejs ( also i've had some contribtutions to the node-mongodb-native driver). You can check out some public work done here: https://github.com/alinsilvian Thanks

€100 EUR dalam sehari
(0 Ulasan)
0.0
Crum

Hello ! im a student of nodejs, and i can do this !

€30 EUR dalam 3 hari
(0 Ulasan)
0.0
l0nwlf

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. :)

€30 EUR dalam 4 hari
(0 Ulasan)
0.0