'use strict';

// global requires
global.logger = require('../utils/Logger').loggers.get('main');
global.utilBanner = require('../utils/UtilBanner');

// print the banner to show the app is starting. This should be as early in the startup as possible, after the logging is set up
var pjson = require('../../package.json');
utilBanner.printStartingBanner(pjson);

global.config = require('../configLoader/Config');
global.SharedConstants = require('../../shared/constants/SharedConstants');

config.load()
.then(function successFunc() {
        logger.info("Configuration loaded, starting queue processor.");

        var dbProvider = require('../database/providers/DatabaseProvider')();
        global.DataService = dbProvider.dataService;
        global.RuleDataService = dbProvider.ruleDataService;

        var server = require('./SystemActionProcessor.js');
        server.start();
    },
    function errorFunc(err) {
        logger.error("Fatal error loading configuration - " + err);
        throw err;
    }
);

