There is a sync-request library that is pretty easy to use. Internally, it synchronously generates a child process and uses then-request , so the parameters are similar to this library.
As others have stated, I would caution against using this in your execution logic. However, this can be very convenient for loading the configuration.
If you download a configuration, another strategy may use a separate script to start your process. Example:
var http = require("http"), cp = require("child_process"); // Starting process if (process.argv.length < 3) { return http.get("http://www.google.com/index.html", function(res) { var config = { statusCode : res.statusCode, headers : res.headers }; cp.fork(module.filename, [JSON.stringify(config)]); }); } // Config provided var config = JSON.parse(process.argv[2]); console.log(config.statusCode);
kjv
source share