<commit_before>/* jslint node: true, esnext: true */
"use strict";

const http = require('http'),
  https = require('https'),
  Koa = require('kronos-koa'),
  service = require('kronos-service');

// The under the configuration is registered
const DEFAULT_PORT = 9898;

function createService(name, values) {
  if (!values) values = {};

  values.koa = new Koa();
  if (!values.port) values.port = DEFAULT_PORT;

  values._start = function () {
    if (!this.server) {
      this.server = http.createServer(this.koa.callback());

      return new Promise((fullfill, reject) => {
        this.info(level => `Starting http server on port ${this.port}`);

        try {
          this.server.listen(this.port, err => {
            if (err) {
              this.server = undefined;
              reject(err);
            } else {
              fullfill(this);
            }
          });
        } catch (e) {
          this.error(e);
        }
      });
    }

    return Promise.resolve(this);
  };

  values._stop = function () {
    if (this.koa.hasMiddleware() || !this.server) return Promise.resolve(this);

    return new Promise((fulfill, reject) => {
      // no more middleware registered. Stop the http server
      this.info("Stopping http server");

      this.server.close(err => {
        if (err) {
          reject(err);
        } else {
          this.server = undefined;
          fulfill(this);
        }
      });
    });
  };

  return service.createService(name, values);
}

module.exports.registerWithManager = function (manager) {
  manager.serviceRegister(createService('koa', {}));
}<commit_msg>style: added missing semi-colons<commit_after>/* jslint node: true, esnext: true */
"use strict";

const http = require('http'),
  https = require('https'),
  Koa = require('kronos-koa'),
  service = require('kronos-service');

// The under the configuration is registered
const DEFAULT_PORT = 9898;

function createService(name, values) {
  if (!values) values = {};

  values.koa = new Koa();
  if (!values.port) values.port = DEFAULT_PORT;

  values._start = function () {
    if (!this.server) {
      this.server = http.createServer(this.koa.callback());

      return new Promise((fullfill, reject) => {
        this.info(level => `Starting http server on port ${this.port}`);

        try {
          this.server.listen(this.port, err => {
            if (err) {
              this.server = undefined;
              reject(err);
            } else {
              fullfill(this);
            }
          });
        } catch (e) {
          this.error(e);
        }
      });
    }

    return Promise.resolve(this);
  };

  values._stop = function () {
    if (this.koa.hasMiddleware() || !this.server) return Promise.resolve(this);

    return new Promise((fulfill, reject) => {
      // no more middleware registered. Stop the http server
      this.info("Stopping http server");

      this.server.close(err => {
        if (err) {
          reject(err);
        } else {
          this.server = undefined;
          fulfill(this);
        }
      });
    });
  };

  return service.createService(name, values);
}

module.exports.registerWithManager = function (manager) {
  manager.serviceRegister(createService('koa', {}));
};
{'fraction_non_alphanumeric': 0.14772727272727273, 'fraction_numerical': 0.002457002457002457, 'mean_word_length': 2.2407960199004977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3045571', 'n_tokens_mistral': 974, 'n_tokens_neox': 954, 'n_words': 219}