<commit_before>'use strict';


const { EngineStartupError } = require('../error');
const { setLogger } = require('../utilities');
const { processOptions } = require('../options');
const { httpStartServer } = require('./http');


/**
 * Start server for each protocol, for the moment only HTTP
 *
 * @param {object} options
 * @param {object} options.idl - IDL definitions
 */
const startServer = async function (options) {
  try {
    const opts = await processOptions(options);

    if (opts.logger) {
      setLogger({ logger: opts.logger });
    }

    const server = await Promise.all([
      httpStartServer(opts),
    ]);
    return server;
  // Make sure all exceptions thrown at startup follow
  // the EngineStartupError signature
  } catch (innererror) {
    if (innererror instanceof EngineStartupError) {
      throw innererror;
    } else {
      throw new EngineStartupError(innererror.message, {
        reason: 'UNKNOWN',
        innererror,
      });
    }
  }
};


module.exports = {
  startServer,
};<commit_msg>Return servers as a map not an array<commit_after>'use strict';


const { EngineStartupError } = require('../error');
const { setLogger } = require('../utilities');
const { processOptions } = require('../options');
const { httpStartServer } = require('./http');


/**
 * Start server for each protocol, for the moment only HTTP
 *
 * @param {object} options
 * @param {object} options.idl - IDL definitions
 */
const startServer = async function (options) {
  try {
    const opts = await processOptions(options);

    if (opts.logger) {
      setLogger({ logger: opts.logger });
    }

    // Make sure all servers are starting concurrently, not serially
    const [http] = await Promise.all([
      httpStartServer(opts),
    ]);
    const servers = { http };
    return servers;
  // Make sure all exceptions thrown at startup follow
  // the EngineStartupError signature
  } catch (innererror) {
    if (innererror instanceof EngineStartupError) {
      throw innererror;
    } else {
      throw new EngineStartupError(innererror.message, {
        reason: 'UNKNOWN',
        innererror,
      });
    }
  }
};


module.exports = {
  startServer,
};
{'fraction_non_alphanumeric': 0.1276887871853547, 'fraction_numerical': 0.0, 'mean_word_length': 3.0183823529411766, 'pattern_counts': {'":': 0, '<': 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': '2601674', 'n_tokens_mistral': 616, 'n_tokens_neox': 625, 'n_words': 183}