Comparing version 1.1.5 to 1.2.0
#!/usr/bin/env node | ||
var fs = require('fs'); | ||
var filePath = 'heapdump.json'; | ||
var libpath = require('path'); | ||
var filePath = '/tmp/heapdump.json'; | ||
var heapdump = require('heapdump'); | ||
@@ -9,10 +10,9 @@ var nodereport = require('node-report'); | ||
var storedir = require('./config.json'); | ||
var express = require('express'); | ||
fs.watchFile(filePath, function(event, filename) { | ||
if(filename){ | ||
try{ | ||
file = fs.readFileSync(filePath); | ||
jsonfile.readFile(filePath, function(err, obj) { | ||
console.dir(obj.type); | ||
//console.dir(obj.type); | ||
if(obj.type == 'heap'){ | ||
@@ -25,6 +25,6 @@ | ||
else if (obj.type == 'report'){ | ||
nodereport.setFileName("myreport" +Date.now() +"taken "); | ||
nodereport.setFileName("Nodejsreport" +Date.now() +"taken"); | ||
nodereport.setDirectory(storedir.defaultpath); | ||
nodereport.triggerReport(); | ||
console.log('take report'); | ||
console.log('Took report'); | ||
} | ||
@@ -39,3 +39,2 @@ else{ | ||
} | ||
// console.log('File content at : ' + new Date() + ' is \n' + file); | ||
} | ||
@@ -46,20 +45,20 @@ else{ | ||
}); | ||
function generateHeapDumpAndStats(){ | ||
console.log('Took heapdump'); | ||
heapdump.writeSnapshot(storedir.defaultpath+'foo' + Date.now() + '.heapsnapshot'); | ||
heapdump.writeSnapshot(storedir.defaultpath+'HeapDump' + Date.now() + '.heapsnapshot'); | ||
} | ||
///Users/ssjain/WebstormProjects/untitled1 | ||
module.exports = function(config) { | ||
config = config || {}; | ||
config.filepath = config.filepath || '/tmp/'; | ||
// TODO -- figure out how to get `config` into handlers | ||
var router = express.Router(); | ||
module.exports = function() { | ||
return function(req, res, next) { | ||
console.log('Hello World')// Implement the middleware function based on the options object | ||
var file = req.params.file, path = storedir.defaultpath + '/' + file; | ||
router.get('/', function (req, res, next) { | ||
fs.readdir(storedir.defaultpath, function (err, filenames) { | ||
if (err) { | ||
console.log(err); | ||
req.error = err; | ||
res.status(500).send('error!'); | ||
return; | ||
} | ||
@@ -69,3 +68,3 @@ var heapdump = []; | ||
filenames.forEach(function (filename) { | ||
console.log(filename) | ||
//console.log(filename) | ||
if (filename.indexOf("heapsnapshot")>-1) { | ||
@@ -75,17 +74,26 @@ heapdump.push(filename); | ||
} | ||
else if (filename.indexOf("myreport")>-1) { | ||
else if (filename.indexOf("taken")>-1) { | ||
report.push(filename); | ||
} | ||
}); | ||
var html = ''; | ||
html += '<ul>'; | ||
heapdump.forEach(function(item) { | ||
html += '<li><a href="' + encodeURIComponent(item) + '">' + encodeURIComponent(item) + '</a>'; | ||
}); | ||
report.forEach(function(item) { | ||
html += '<li><a href="' + encodeURIComponent(item) + '">' + encodeURIComponent(item) + '</a>'; | ||
}); | ||
html += '</ul>'; | ||
res.type('text/html').send(html); | ||
}); | ||
}); | ||
router.get('*', function(req, res) { | ||
var path = libpath.join(storedir.defaultpath, req.url); | ||
res.download(path); | ||
}); | ||
}); | ||
console.log(heapdump) | ||
res.locals.heapdumpList= heapdump; | ||
res.locals.reportList = report; | ||
next(); | ||
}); | ||
} | ||
} | ||
return router; | ||
} |
{ | ||
"name": "heapware", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "trigger and export heap dumps rhel7 ", | ||
@@ -5,0 +5,0 @@ "main": "my-middleware.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32255
124