{"size": 1650, "ext": "js", "max_stars_repo_path": "lib/commands/proxy.js", "max_stars_repo_name": "rwd/node-cluster-service", "max_stars_repo_stars_event_min_datetime": "2015-01-14T18:19:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-13T17:24:45.000Z", "max_issues_repo_path": "lib/commands/proxy.js", "max_issues_repo_name": "rwd/node-cluster-service", "max_issues_repo_issues_event_min_datetime": "2015-02-02T16:26:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-21T13:18:59.000Z", "max_forks_repo_path": "lib/commands/proxy.js", "max_forks_repo_name": "rwd/node-cluster-service", "max_forks_repo_forks_event_min_datetime": "2015-02-17T17:11:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-20T07:13:57.000Z"}
{"max_stars_count": 147, "max_issues_count": 23, "max_forks_count": 24, "avg_line_length": 27.9661016949, "max_line_length": 71, "alphanum_fraction": 0.5927272727}
var cservice = require("../../cluster-service");

module.exports = function(evt, cb, cmd) {
  var versionStr, options;
  switch (cmd) {
    case "start":
      cservice.proxy.start({ configPath: arguments[3] }, cb);
      break;
    case "stop":
      cservice.proxy.stop(cb);
      break;
    case "version":
      versionStr = arguments[3];
      options = {};
      if (arguments[4]) {
        options.workerCount = parseInt(arguments[4]);
      }
      cservice.proxy.version(versionStr, options, cb);
      break;
    case "promote":
      versionStr = arguments[3];
      options = {};
      if (arguments[4]) {
        options.workerCount = parseInt(arguments[4]);
      }
      cservice.proxy.promote(versionStr, options, cb);
      break;
    case "info":
      cservice.proxy.info(cb);
      break;
    default:
      cb("Proxy command " + cmd +
        " not recognized. Try 'help proxy' for more info.");
      break;
  }
};

module.exports.more = function(cb) {
  cb(null, {
    command: "proxy {cmd} {options}",
    info: "Perform a proxy operation.",
    cmd: "Available commands:",
    "* start {configPath}": "Start proxy",
    "* stop": "Stop proxy",
    "* version {version} {workerCount}":
      "Set a given version to desired worker count",
    "* promote {version} [workerCount]": "Promote a worker version",
    "* info": "Return proxy info, including a list of active versions",
    "options": "Available options:",
    "* configPath": "Path of proxy config file",
    "* version": "Worker version (path)",
    "* workerCount": "Desired number of workers"
  });
};

module.exports.control = function() {
  return "local";
};
