<commit_before>var api = require('./api');
var async = require('async');
var auth = require('./auth');
var deploy = require('./deploy');
var etcd = require('./etcd');
var express = require('express');
var http = require('http');
var mkdirp = require('mkdirp');
var path = require('path');
var registry = require('etcd-registry');
var sprintf = require('sprintf').sprintf;
var url = require('url');
var _ = require('underscore');


var log = require('logmagic').local('virgo-upgrade-service.lib.entry');

var logmagic = require('logmagic');
logmagic.route('__root__', logmagic['DEBUG'], 'console');


function die(msg) {
  console.log(msg);
  process.exit(1);
}


/**
 * @param options
 * @return 
 */
function entry(options) {
  var app = express(),
      server = http.createServer(app),
      services,
      authDb,
      de,
      value,
      l;

  /* required options */
  options.etcd_host = process.env.VIRGO_UPDATE_SERVICE_ETCD_HOST;
  if (!options.etcd_host) {
    die('VIRGO_UPDATE_SERVICE_ETCD_HOST is missing');
  }
  options.etcd_port = process.env.VIRGO_UPDATE_SERVICE_ETCD_PORT;
  if (!options.etcd_port) {
    die('VIRGO_UPDATE_SERVICE_ETCD_PORT is missing');
  }
  options.bind_host = process.env.VIRGO_UPDATE_SERVICE_BIND_HOST;
  if (!options.bind_host) {
    die('VIRGO_UPDATE_SERVICE_BIND_HOST is missing');
  }
  options.bind_port = process.env.VIRGO_UPDATE_SERVICE_BIND_PORT;
  if (!options.bind_port) {
    die('VIRGO_UPDATE_SERVICE_BIND_PORT is missing');
  }
  options.secret = process.env.VIRGO_UPDATE_SERVICE_SECRET;
  if (!options.secret) {
    die('VIRGO_UPDATE_SERVICE_SECRET is missing');
  }
  options.htpasswd_file = process.env.VIRGO_UPDATE_SERVICE_HTPASSWD_FILE;
  if (!options.htpasswd_file) {
    die('VIRGO_UPDATE_SERVICE_HTPASSWD_FILE is missing');
  }
  options.default_channels = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS;
  if (!options.default_channels) {
    die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS is missing');
  } else {
    options.default_channels = options.default_channels.split(',');
  }
  options.default_channel_version = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION;
  if (!options.default_channel_version) {
    die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION is missing');
  }
  options.pkgbackend = process.env.VIRGO_UPDATE_PACKAGE_BACKEND;
  if (!options.pkgbackend) {
    options.pkgbackend = 'pkgcloud';;
  }
  options.pkgcloud.username = process.env.VIRGO_UPDATE_SERVICE_PKGCLOUD_USERNAME;
  if (options.pkgbackend === 'pkgcloud' && !options.pkgcloud.username) {
    die('VIRGO_UPDATE_SERVICE_PKGCLOUD_USERNAME is missing');
  }
  options.pkgcloud.apiKey = process.env.VIRGO_UPDATE_SERVICE_PKGCLOUD_APIKEY;
  if (options.pkgbackend === 'pkgcloud' && !options.pkgcloud.apiKey) {
    die('VIRGO_UPDATE_SERVICE_PKGCLOUD_APIKEY is missing');
  }
  value = process.env.VIRGO_UPDATE_SERVICE_EXE_DIR;
  if (value) {
    options.exe_dir = value;
  }
  value = process.env.VIRGO_UPDATE_VERSION_CACHE_TTL;
  if (value) {
    options.version_cache_timeout = value.parseInt();
  }

  /* optional options */
  value = process.env.VIRGO_UPDATE_SERVICE_PUBLIC_HOST;
  if (value) {
    options.addr_host = value;
  } else {
    options.addr_host = options.bind_host;
  }
  value = process.env.VIRGO_UPDATE_SERVICE_PUBLIC_PORT;
  if (value) {
    options.addr_port =  value;
  } else {
    options.addr_port = options.bind_port;
  }
  value = process.env.VIRGO_UPDATE_SERVICE_NAME;
  if (value) {
    options.service_name = value;
  }

  function optionsMiddleware(req, res, next) {
    req.globalOptions = options;
    req.authDb = authDb;
    next();
  }

  etcd.setEndpoints(options.etcd_host + ':' + options.etcd_port);<commit_msg>fix value for cache timeout<commit_after>var api = require('./api');
var async = require('async');
var auth = require('./auth');
var deploy = require('./deploy');
var etcd = require('./etcd');
var express = require('express');
var http = require('http');
var mkdirp = require('mkdirp');
var path = require('path');
var registry = require('etcd-registry');
var sprintf = require('sprintf').sprintf;
var url = require('url');
var _ = require('underscore');


var log = require('logmagic').local('virgo-upgrade-service.lib.entry');

var logmagic = require('logmagic');
logmagic.route('__root__', logmagic['DEBUG'], 'console');


function die(msg) {
  console.log(msg);
  process.exit(1);
}


/**
 * @param options
 * @return 
 */
function entry(options) {
  var app = express(),
      server = http.createServer(app),
      services,
      authDb,
      de,
      value,
      l;

  /* required options */
  options.etcd_host = process.env.VIRGO_UPDATE_SERVICE_ETCD_HOST;
  if (!options.etcd_host) {
    die('VIRGO_UPDATE_SERVICE_ETCD_HOST is missing');
  }
  options.etcd_port = process.env.VIRGO_UPDATE_SERVICE_ETCD_PORT;
  if (!options.etcd_port) {
    die('VIRGO_UPDATE_SERVICE_ETCD_PORT is missing');
  }
  options.bind_host = process.env.VIRGO_UPDATE_SERVICE_BIND_HOST;
  if (!options.bind_host) {
    die('VIRGO_UPDATE_SERVICE_BIND_HOST is missing');
  }
  options.bind_port = process.env.VIRGO_UPDATE_SERVICE_BIND_PORT;
  if (!options.bind_port) {
    die('VIRGO_UPDATE_SERVICE_BIND_PORT is missing');
  }
  options.secret = process.env.VIRGO_UPDATE_SERVICE_SECRET;
  if (!options.secret) {
    die('VIRGO_UPDATE_SERVICE_SECRET is missing');
  }
  options.htpasswd_file = process.env.VIRGO_UPDATE_SERVICE_HTPASSWD_FILE;
  if (!options.htpasswd_file) {
    die('VIRGO_UPDATE_SERVICE_HTPASSWD_FILE is missing');
  }
  options.default_channels = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS;
  if (!options.default_channels) {
    die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS is missing');
  } else {
    options.default_channels = options.default_channels.split(',');
  }
  options.default_channel_version = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION;
  if (!options.default_channel_version) {
    die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION is missing');
  }
  options.pkgbackend = process.env.VIRGO_UPDATE_PACKAGE_BACKEND;
  if (!options.pkgbackend) {
    options.pkgbackend = 'pkgcloud';;
  }
  options.pkgcloud.username = process.env.VIRGO_UPDATE_SERVICE_PKGCLOUD_USERNAME;
  if (options.pkgbackend === 'pkgcloud' && !options.pkgcloud.username) {
    die('VIRGO_UPDATE_SERVICE_PKGCLOUD_USERNAME is missing');
  }
  options.pkgcloud.apiKey = process.env.VIRGO_UPDATE_SERVICE_PKGCLOUD_APIKEY;
  if (options.pkgbackend === 'pkgcloud' && !options.pkgcloud.apiKey) {
    die('VIRGO_UPDATE_SERVICE_PKGCLOUD_APIKEY is missing');
  }
  value = process.env.VIRGO_UPDATE_SERVICE_EXE_DIR;
  if (value) {
    options.exe_dir = value;
  }
  value = process.env.VIRGO_UPDATE_VERSION_CACHE_TTL;
  if (value) {
    options.version_cache_timeout = value;
  }

  /* optional options */
  value = process.env.VIRGO_UPDATE_SERVICE_PUBLIC_HOST;
  if (value) {
    options.addr_host = value;
  } else {
    options.addr_host = options.bind_host;
  }
  value = process.env.VIRGO_UPDATE_SERVICE_PUBLIC_PORT;
  if (value) {
    options.addr_port =  value;
  } else {
    options.addr_port = options.bind_port;
  }
  value = process.env.VIRGO_UPDATE_SERVICE_NAME;
  if (value) {
    options.service_name = value;
  }

  function optionsMiddleware(req, res, next) {
    req.globalOptions = options;
    req.authDb = authDb;
    next();
  }

  etcd.setEndpoints(options.etcd_host + ':' + options.etcd_port);
{'fraction_non_alphanumeric': 0.1282535401213756, 'fraction_numerical': 0.00026972353337828726, 'mean_word_length': 4.5675675675675675, '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': '3784434', 'n_tokens_mistral': 2609, 'n_tokens_neox': 2633, 'n_words': 403}