Ejemplo n.º 1
0
common.createPool = function(config) {
  config = mergeTestConfig(config);
  config.connectionConfig = mergeTestConfig(config.connectionConfig);
  return Mysql.createPool(config);
};
Ejemplo n.º 2
0
function initApp() {

    app = express();
    httpServer = http.Server(app);

    app.use(logger('combined')); //logger
    
    // 정적 디렉토리 셋팅
    app.use(express.static(path.join(__dirname, 'app/www')));

    app.get('/', function(req, res) {
        res.sendFile(path.join(__dirname, 'app/www/index.html'));
    });

    // get our request parameters
    app.use(bodyParser.urlencoded({
        extended: false
    }));
    app.use(bodyParser.json());
    
    // 추가
    require('./routes')(app);

    app.use(handleError);

    /*
    // catch 404 and forward to error handler
    app.use(function(req, res, next) {
        var err = new Error('Not Found');
        err.status = 404;
        next(err);
    });
    */
    
    httpServer.on('connection', function(conn) {
        var key = conn.remoteAddress + ':' + (conn.remotePort || '');
        console.log(key);
        openHttpConnections[key] = conn;

        conn.on('close', function() {
            delete openHttpConnections[key];
        });
    });
    /*
    database.addBuildupSql({
        sql: "BEGIN EXECUTE IMMEDIATE q'[alter session set NLS_DATE_FORMAT='DD-MM-YYYY']'; END;"
    });

    database.addTeardownSql({
        sql: "BEGIN sys.dbms_session.modify_package_state(sys.dbms_session.reinitialize); END;"
    });
    */
    database.createPool(dbconfig)
        .then(function() {

            httpServer.listen(port, function() {
                console.log('Webserver listening on port:' + port);
            });
        })
        .catch(function(err) {
            console.error('Error occurred creating database connection pool', err);
            console.log('Exiting process');
            process.exit(0);
        });
    
}