/**
 * @module Start
 *
 * Start the application.
 */

var CONFIG = require('./config/config');
var App = require('./app');
var debug = require('debug')('socialbot:start');

// Create a fully configured express application.
App.create(function (app) {
	app.init(CONFIG[app.get('env')]);
	app.start(function (err, server) {
		if (err) {
			debug('Start app error: ', err);
			process.exit(1);
		} else {
			debug('Server listening on port: ', server.address().port);
		}
	});
});
