Skip to content

Commit

Permalink
feat: allow to close mysql trace
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Sep 26, 2018
1 parent 938a14d commit 25a9030
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
20 changes: 5 additions & 15 deletions common/sequelize.js
@@ -1,19 +1,5 @@
/**!
* cnpmjs.org - common/sequelize.js
*
* Copyright(c) fengmk2 and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
*/

'use strict';

/**
* Module dependencies.
*/

var Sequelize = require('sequelize');
var DataTypes = require('sequelize/lib/data-types');
var config = require('../config');
Expand All @@ -35,6 +21,7 @@ if (config.mysqlServers && config.database.dialect === 'sqlite') {

console.warn('[WARNNING] your config.js was too old, please @see https://github.com/cnpm/cnpmjs.org/wiki/Migrating-from-1.x-to-2.x');
var server = config.mysqlServers[0];
var dialectOptions = config.database && config.database.dialectOptions;
config.database = {
db: config.mysqlDatabase,
username: server.user,
Expand All @@ -45,10 +32,13 @@ if (config.mysqlServers && config.database.dialect === 'sqlite') {
pool: {
maxConnections: config.mysqlMaxConnections || 10,
minConnections: 0,
maxIdleTime: 30000
maxIdleTime: 30000,
},
logging: !!process.env.SQL_DEBUG,
};
if (dialectOptions) {
config.database.dialectOptions = dialectOptions;
}
}

var database = config.database;
Expand Down
5 changes: 5 additions & 0 deletions config/index.js
Expand Up @@ -121,6 +121,11 @@ var config = {
maxIdleTime: 30000
},

dialectOptions: {
// if your server run on full cpu load, please set trace to false
trace: true,
},

// the storage engine for 'sqlite'
// default store into ~/.cnpmjs.org/data.sqlite
storage: path.join(dataDir, 'data.sqlite'),
Expand Down

0 comments on commit 25a9030

Please sign in to comment.