<commit_before>var http = require('http'),
	path = require('path'),
	fs = require('fs'),
	async = require('async'),
	Sandal = require('sandal').extend(require('sandal-autowire'));

module.exports = function(options, callback) {

	if (!callback) {
		callback = options;
		options = {};
	}

	if (!(options instanceof Array)) {
		return createSite(options, function (err, app) {
			if (err) return callback(err);
			callback(null, http.createServer(function (req, res) {
				app(req, res);
			}));
		});
	}

	var error = optionsArrayError(options);
	if (error) return callback(error);

	var startedSites = 0;
	var siteCount = options.length;
	var requestQueue = [];

	var apps = options.reduce(function (apps, options) {
		createSite(options, function (err, app) {
			if (err) {
				console.error(err);
				process.exit(-1);
			}
			options.hosts.forEach(function (host) {
				apps[host] = app;
			});
			startedSites++;
			if (startedSites === siteCount && requestQueue) {
				requestQueue.forEach(function (requestQueueItem) {
					requestQueueItem();
				});
				requestQueue = null;
			}
		});
		return apps;
	}, {});

	if (error) return callback(error);

	callback(null, http.createServer(function (req, res) {
		if (!req || !req.headers || !req.headers.host) {
			res.writeHead(400, {'Content-Type': 'text/plain'});
			res.end('No host header provided\n');
			return;
		}
		var requestQueueItem = function () {
			var app = apps[req.headers.host] || apps['*'];<commit_msg>Errors in createSite will now print stack trace<commit_after>var http = require('http'),
	path = require('path'),
	fs = require('fs'),
	async = require('async'),
	Sandal = require('sandal').extend(require('sandal-autowire'));

module.exports = function(options, callback) {

	if (!callback) {
		callback = options;
		options = {};
	}

	if (!(options instanceof Array)) {
		return createSite(options, function (err, app) {
			if (err) return callback(err);
			callback(null, http.createServer(function (req, res) {
				app(req, res);
			}));
		});
	}

	var error = optionsArrayError(options);
	if (error) return callback(error);

	var startedSites = 0;
	var siteCount = options.length;
	var requestQueue = [];

	var apps = options.reduce(function (apps, options) {
		createSite(options, function (err, app) {
			if (err) {
				console.error(err.stack);
				process.exit(-1);
			}
			options.hosts.forEach(function (host) {
				apps[host] = app;
			});
			startedSites++;
			if (startedSites === siteCount && requestQueue) {
				requestQueue.forEach(function (requestQueueItem) {
					requestQueueItem();
				});
				requestQueue = null;
			}
		});
		return apps;
	}, {});

	if (error) return callback(error);

	callback(null, http.createServer(function (req, res) {
		if (!req || !req.headers || !req.headers.host) {
			res.writeHead(400, {'Content-Type': 'text/plain'});
			res.end('No host header provided\n');
			return;
		}
		var requestQueueItem = function () {
			var app = apps[req.headers.host] || apps['*'];
{'fraction_non_alphanumeric': 0.16956521739130434, 'fraction_numerical': 0.0033444816053511705, 'mean_word_length': 3.8792822185970635, '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': '5020095', 'n_tokens_mistral': 1117, 'n_tokens_neox': 964, 'n_words': 224}