ffffng/server/main.js
baldo 2dc7ad0c23 Fix: More asynchronous glob operations and graceful-fs.
Hope this fixes the "Error: EMFILE, too many open files" in
NodeInformationRetrievalJob.

See: https://github.com/freifunkhamburg/ffffng/issues/13
2016-06-21 22:59:37 +02:00

59 lines
1.4 KiB
JavaScript
Executable file

#!/usr/bin/env node
/*jslint node: true */
'use strict';
// Dirty hack to allow usage of angular modules.
global.angular = require('ng-di');
angular.module('ffffng', []);
(function () {
// Use graceful-fs instead of fs also in all libraries to have more robust fs handling.
var realFs = require('fs');
var gracefulFs = require('graceful-fs');
gracefulFs.gracefulify(realFs);
})();
require('./config');
require('./logger').tag('main', 'startup').info('Server starting up...');
require('./app');
require('./router');
require('./libs');
require('./utils/errorTypes');
require('./utils/resources');
require('./utils/strings');
require('./utils/urlBuilder');
require('./resources/frontendResource');
require('./resources/taskResource');
require('./resources/mailResource');
require('./resources/nodeResource');
require('./resources/monitoringResource');
require('./services/mailService');
require('./services/mailTemplateService');
require('./services/nodeService');
require('./services/monitoringService');
require('../shared/validation/constraints');
require('./validation/validator');
require('./jobs/scheduler');
var db = require('./db/database');
db.init(function () {
angular.injector(['ffffng']).invoke(function (config, app, Logger, Scheduler, Router) {
Logger.tag('main').info('Initializing...');
Scheduler.init();
Router.init();
app.listen(config.server.port, '::');
module.exports = app;
});
});