mirror of
https://github.com/Cameri/nostream.git
synced 2025-03-17 21:31:48 +01:00
chore: log conn pool every min
Signed-off-by: Ricardo Arturo Cabral Mejía <me@ricardocabral.io>
This commit is contained in:
parent
199fa55ea3
commit
a505659d67
@ -4,13 +4,15 @@ import knex, { Knex } from 'knex'
|
||||
import { createLogger } from '../factories/logger-factory'
|
||||
|
||||
((knex) => {
|
||||
const counters = {}
|
||||
const lastUpdate = {}
|
||||
knex.Client.prototype.releaseConnection = function (connection) {
|
||||
const released = this.pool.release(connection)
|
||||
|
||||
if (released) {
|
||||
counters[this.config.tag] = (counters[this.config.tag] ?? 0) + 1
|
||||
if (counters[this.config.tag] % 10 === 0) {
|
||||
const now = new Date().getTime()
|
||||
lastUpdate[this.config.tag] = lastUpdate[this.config.tag] ?? now
|
||||
if (now - lastUpdate[this.config.tag] >= 60000) {
|
||||
lastUpdate[this.config.tag] = now
|
||||
console.log(`${this.config.tag} connection pool: ${this.pool.numUsed()} used / ${this.pool.numFree()} free / ${this.pool.numPendingAcquires()} pending`)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user