mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-05 05:59:30 +01:00
Adding the functionality of configuring the host to bind the server. By default this is set to 0.0.0.0.
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Module dependencies.
|
|
*/
|
|
var config = require('../config'),
|
|
mongoose = require('./mongoose'),
|
|
express = require('./express'),
|
|
chalk = require('chalk'),
|
|
seed = require('./seed');
|
|
|
|
function seedDB() {
|
|
if (config.seedDB && config.seedDB.seed) {
|
|
console.log(chalk.bold.red('Warning: Database seeding is turned on'));
|
|
seed.start();
|
|
}
|
|
}
|
|
|
|
// Initialize Models
|
|
mongoose.loadModels(seedDB);
|
|
|
|
module.exports.loadModels = function loadModels() {
|
|
mongoose.loadModels();
|
|
};
|
|
|
|
module.exports.init = function init(callback) {
|
|
mongoose.connect(function (db) {
|
|
// Initialize express
|
|
var app = express.init(db);
|
|
if (callback) callback(app, db, config);
|
|
|
|
});
|
|
};
|
|
|
|
module.exports.start = function start(callback) {
|
|
var _this = this;
|
|
|
|
_this.init(function (app, db, config) {
|
|
|
|
// Start the app by listening on <port> at <host>
|
|
app.listen(config.port, config.host, function () {
|
|
|
|
// Logging initialization
|
|
console.log('--');
|
|
console.log(chalk.green(config.app.title));
|
|
console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
|
|
console.log(chalk.green('Port:\t\t\t\t' + config.port));
|
|
console.log(chalk.green('Database:\t\t\t\t' + config.db.uri));
|
|
if (process.env.NODE_ENV === 'secure') {
|
|
console.log(chalk.green('HTTPs:\t\t\t\ton'));
|
|
}
|
|
console.log(chalk.green('App version:\t\t\t' + config.meanjs.version));
|
|
if (config.meanjs['meanjs-version'])
|
|
console.log(chalk.green('MEAN.JS version:\t\t\t' + config.meanjs['meanjs-version']));
|
|
console.log('--');
|
|
|
|
if (callback) callback(app, db, config);
|
|
});
|
|
|
|
});
|
|
|
|
};
|