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

View File

@ -21,6 +21,7 @@ var pkg_file = '../package.yaml'
, commander = require('commander')
, server = require('./index')
, crypto = require('crypto')
, Path = require('path')
, pkg = yaml.safeLoad(fs.readFileSync(__dirname + '/' + pkg_file, 'utf8'))
commander
@ -101,7 +102,7 @@ function get_hostport() {
function afterConfigLoad() {
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)

View File

@ -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(function(err, req, res, next) {
if (typeof(res.report_error) !== 'function') {

View File

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

View File

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