<commit_before>var
	util = require("util"),
	request = require("request"),
	querystring = require("querystring"),
	options = null,
	cservice = require("../cluster-service")
;

exports.start = function(o, cb) {
	options = o;

	run(options.run, cb);
};

function run(question, cb) {
	var split = question.split(" ");
	var qs = querystring.stringify({
		cmd: question,
		accessKey: options.accessKey
	});
	var url = "http://" + (options.host || "localhost") + ":" + (options.port || 11987) + "/cli"
		+ "?" + qs
	;
	cservice.log("Running remote command: ".warn + url.data);
	request.post(url, function (err, res, body) {
	    if (res.statusCode !== 200 && !err && body) {
	        err = body;
	    }
	    if (err) {
			cservice.error("Error: ", err);
			body = { statusCode: res.statusCode, error: err };
		} else if (body) {
			if (typeof body === "string" && (body.indexOf("{") === 0 || body.indexOf("[") === 0)) {
				body = JSON.parse(body); // deserialize
			}
		}
		if (options.json === true) {
			cservice.results(JSON.stringify(body));
		} else {
			cservice.results(util.inspect(body, { depth: null, colors: true }));
		}
		
		cb && cb(err, body);
	});
}<commit_msg>#23 fix status code error on 'run' if error<commit_after>var
	util = require("util"),
	request = require("request"),
	querystring = require("querystring"),
	options = null,
	cservice = require("../cluster-service")
;

exports.start = function(o, cb) {
	options = o;

	run(options.run, cb);
};

function run(question, cb) {
	var split = question.split(" ");
	var qs = querystring.stringify({
		cmd: question,
		accessKey: options.accessKey
	});
	var url = "http://" + (options.host || "localhost") + ":" + (options.port || 11987) + "/cli"
		+ "?" + qs
	;
	cservice.log("Running remote command: ".warn + url.data);
	request.post(url, function (err, res, body) {
	    if (res && res.statusCode !== 200 && !err && body) {
	        err = body;
	    }
	    if (err) {
			cservice.error("Error: ", err);
			body = { statusCode: res ? res.statusCode : "no response", error: err };
		} else if (body) {
			if (typeof body === "string" && (body.indexOf("{") === 0 || body.indexOf("[") === 0)) {
				body = JSON.parse(body); // deserialize
			}
		}
		if (options.json === true) {
			cservice.results(JSON.stringify(body));
		} else {
			cservice.results(util.inspect(body, { depth: null, colors: true }));
		}
		
		cb && cb(err, body);
	});
}
{'fraction_non_alphanumeric': 0.20432792342904701, 'fraction_numerical': 0.009155222638368706, 'mean_word_length': 3.323741007194245, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2515004', 'n_tokens_mistral': 919, 'n_tokens_neox': 832, 'n_words': 198}