1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

add stuff for testing against fd leaks and memory leaks

This commit is contained in:
Alex Kocharin 2014-08-15 01:37:46 +04:00
parent fdbde9eb87
commit 5dd720cc21
4 changed files with 23 additions and 1 deletions

@ -21,6 +21,7 @@ var pkg_file = '../package.yaml'
, commander = require('commander') , commander = require('commander')
, server = require('./index') , server = require('./index')
, crypto = require('crypto') , crypto = require('crypto')
, Path = require('path')
, pkg = yaml.safeLoad(fs.readFileSync(__dirname + '/' + pkg_file, 'utf8')) , pkg = yaml.safeLoad(fs.readFileSync(__dirname + '/' + pkg_file, 'utf8'))
commander commander
@ -101,7 +102,7 @@ function get_hostport() {
function afterConfigLoad() { function afterConfigLoad() {
if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version
if (!config.self_path) config.self_path = config_path if (!config.self_path) config.self_path = Path.resolve(config_path)
logger.setup(config.logs) logger.setup(config.logs)

@ -498,6 +498,21 @@ module.exports = function(config_hash) {
}) })
}) })
// hook for tests only
if (config._debug) {
app.get('/-/_debug', function(req, res) {
var do_gc = typeof(global.gc) !== 'undefined'
if (do_gc) global.gc()
res.send({
pid: process.pid,
main: process.mainModule.filename,
conf: config.self_path,
mem: process.memoryUsage(),
gc: do_gc,
})
})
}
app.use(app.router) app.use(app.router)
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
if (typeof(res.report_error) !== 'function') { if (typeof(res.report_error) !== 'function') {

@ -57,3 +57,6 @@ packages:
allow_access: none allow_access: none
listen: 55551 listen: 55551
# expose internal methods
_debug: true

@ -37,3 +37,6 @@ packages:
allow_publish: test anonymous allow_publish: test anonymous
listen: 55552 listen: 55552
# expose internal methods
_debug: true