// Create a MySQL connection pool with
// a max of 10 connections, a min of 2, and a 30 second max idle time
var Pool = require('generic-pool').Pool
var mysql = require('mysql')// v2.10.x
var pool = new Pool({
name : 'mysql',
create : function(callback) {
var c = mysql.createConnection({
user: 'scott',
password: 'tiger',
database:'mydb'
})
// parameter order: err, resource
callback(null, c)
},
destroy : function(client) { client.end()},
max : 10,
// optional. if you set this, make sure to drain() (see step 3)
min : 2,
// specifies how long a resource can stay idle in pool before being removed
idleTimeoutMillis : 30000,
// if true, logs via console.log - can also be a function
log : true
})
先检查, 你的程序里面的数据库连接是否使用后都关闭。有个方法, 虽然有点笨, 但简单有效。
用记事本写一个bat文件。 内容如下:
net stop "World Wide Web Publishing Service"
net Stop "HTTP SSL"
net Stop "MSSQLSERVER"
net start "World Wide Web Publishing Service"
net start "HTTP SSL"
net start "MSSQLSERVER"
然后加入计划任务里, 让它每天重启一下。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)