<commit_before>	var mod_connect       	= require('connect')
	, mod_sys         		= require('sys')
    , mod_path        		= require('path')
	, mod_resourceservice   = require('./lib/resourceservice.js')
    , mod_modules    		= require('./lib/modules.js')
    , mod_fs          		= require('fs')
    , logger				= require('./lib/logger.js').getLogger('Server')

if (process.argv.length < 3) {
	logger.error('usage: ...');
	process.exit();
}
// [TBD] handle arguments properly
// [TBD] dynamic config service 
var config = null;
mod_fs.readFile(process.argv[2], function (err, data) {
	config = JSON.parse(data);
	logger.info('config loaded');
	mod_resourceservice.configure(config);	
	createServer(config);
});





function createServer(config) {
	var server = mod_connect.createServer(
	    mod_connect.favicon()
	    , mod_connect.router(function (app) {
			    app.get(/^\/modules\/([^\.]*)\/(.*\.js)$/, 			mod_modules.handleScriptRequest);
			    app.get(/^\/modules\/([^\.]*)\/(.*\.html)$/,		mod_modules.handleViewRequest);			   
				app.get(/^\/modules\/([^\.]*)\/controller\/(.*)$/,  mod_modules.handleControllerRequest);
				app.get(/^\/resources(.*)$/,               			mod_resourceservice.handleResourceRequest);
				//app.get(/instances\/(.*)/,             			  mod_instances.handleInstanceRequest);
			}
	    )
	    , mod_connect.static(config.server.documentRoot)		
	    , mod_connect.logger()            
	);
	server.listen(config.server.port);
}

// process.on('SIGINT', function () {
// 	process.exit();
// });<commit_msg>error handling<commit_after>	var mod_connect       	= require('connect')
	, mod_sys         		= require('sys')
    , mod_path        		= require('path')
	, mod_resourceservice   = require('./lib/resourceservice.js')
    , mod_modules    		= require('./lib/modules.js')
    , mod_fs          		= require('fs')
    , logger				= require('./lib/logger.js').getLogger('Server')

if (process.argv.length < 3) {
	logger.error('usage: ...');
	process.exit();
}

// [TBD] handle arguments properly
// [TBD] dynamic config service 
var config = null;
logger.info('reading config from ' + process.argv[2]);
mod_fs.readFile(process.argv[2], function (err, data) {
	if (err) {
		logger.error('error reading configuration');
		process.exit();
	}
	config = JSON.parse(data);
	logger.info('config loaded');
	mod_resourceservice.configure(config);	
	createServer(config);
});





function createServer(config) {
	var server = mod_connect.createServer(
	    mod_connect.favicon()
	    , mod_connect.router(function (app) {
			    app.get(/^\/modules\/([^\.]*)\/(.*\.js)$/, 			mod_modules.handleScriptRequest);
			    app.get(/^\/modules\/([^\.]*)\/(.*\.html)$/,		mod_modules.handleViewRequest);			   
				app.get(/^\/modules\/([^\.]*)\/controller\/(.*)$/,  mod_modules.handleControllerRequest);
				app.get(/^\/resources(.*)$/,               			mod_resourceservice.handleResourceRequest);
				//app.get(/instances\/(.*)/,             			  mod_instances.handleInstanceRequest);
			}
	    )
	    , mod_connect.static(config.server.documentRoot)		
	    , mod_connect.logger()            
	);
	server.listen(config.server.port);
}

// process.on('SIGINT', function () {
// 	process.exit();
// });
{'fraction_non_alphanumeric': 0.1953343701399689, 'fraction_numerical': 0.0015552099533437014, 'mean_word_length': 2.8059171597633137, 'pattern_counts': {'":': 0, '<': 5, '<?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': '439051', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1050, 'n_words': 143}