Comparing version 1.2.2 to 1.2.3
@@ -34,3 +34,3 @@ #!/usr/bin/env node | ||
var filePathd = './heapdump.json'; | ||
var filePathd = '/tmp/config.json'; | ||
@@ -44,8 +44,2 @@ var obj = { | ||
/* json.update('./config.json',{"defaultpath": at.filepath }) | ||
.then(function(dat) { | ||
});*/ | ||
json.update(filePathd,obj) | ||
@@ -52,0 +46,0 @@ .then(function(dat) { |
@@ -5,13 +5,10 @@ #!/usr/bin/env node | ||
var libpath = require('path'); | ||
var filePath = __dirname+'/heapdump.json'; | ||
var filePath ='/tmp/config.json'; | ||
var heapdump = require('heapdump'); | ||
var nodereport = require('node-report'); | ||
var jsonfile = require('jsonfile'); | ||
var storedir = require('./heapdump.json'); | ||
var contents = fs.readFileSync(filePath); | ||
var jsonContent = JSON.parse(contents); | ||
var url = require('url'); | ||
fs.watchFile(filePath, function(event, filename) { | ||
console.log('File Changed !!!'); | ||
if(filename || filename != undefined){ | ||
@@ -57,13 +54,16 @@ try{ | ||
module.exports = function() { | ||
module.exports = function(config) { | ||
return function(req, res, next) { | ||
config.url = config.url || '/tmp/'; | ||
req.parsedUrl = req.parsedUrl || url.parse(req.url, true); | ||
if(((req.parsedUrl.pathname).split('/').slice(-1)[0]).indexOf("heapsnapshot")>-1){ | ||
if((((req.parsedUrl.pathname).split('/').slice(-1)[0]).indexOf("heapsnapshot")>-1) || ((req.parsedUrl.pathname).split('/').slice(-1)[0]).indexOf("taken")>-1) { | ||
console.log('In download'); | ||
console.log(req.parsedUrl.pathname); | ||
res.download(jsonContent.defaultpath+req.parsedUrl.pathname); | ||
res.download(config.url+req.parsedUrl.pathname); | ||
} | ||
else if(((req.parsedUrl.pathname).split('/').slice(-1)[0]).indexOf("getlist")>-1){ | ||
console.log(req.parsedUrl.pathname); | ||
fs.readdir(jsonContent.defaultpath, function (err, filenames) { | ||
console.log(req.parsedUrl.pathname + 'Here in getlist' + config.url); | ||
fs.readdir(config.url, function (err, filenames) { | ||
if (err) { | ||
@@ -89,3 +89,3 @@ console.log(err); | ||
}); | ||
res.render('index',{title:"Express",heapdumpList:heapdump,reportList:report}) | ||
res.render('index',{title:"Express from heapware",heapdumpList:heapdump,reportList:report}) | ||
}); | ||
@@ -100,55 +100,1 @@ | ||
// module.exports = function(config) { | ||
// config = config || {}; | ||
// /* | ||
// changes to be done | ||
// config.url | ||
// config.outputDir | ||
// config.configJson */ | ||
// config.filepath = config.filepath || '/tmp/'; | ||
// // TODO -- figure out how to get `config` into handlers | ||
// var router = express.Router(); | ||
// | ||
// router.get('/', function (req, res, next) { | ||
// fs.readdir(storedir.defaultpath, function (err, filenames) { | ||
// if (err) { | ||
// console.log(err); | ||
// res.status(500).send('error!'); | ||
// return; | ||
// } | ||
// var heapdump = []; | ||
// var report = []; | ||
// filenames.forEach(function (filename) { | ||
// //console.log(filename) | ||
// if (filename.indexOf("heapsnapshot")>-1) { | ||
// heapdump.push(filename); | ||
// | ||
// } | ||
// else if (filename.indexOf("taken")>-1) { | ||
// report.push(filename); | ||
// } | ||
// }); | ||
// var html = ''; | ||
// html += '<ul>'; | ||
// html += '<header> <h1>Heap Dumps</h1> </header>' | ||
// heapdump.forEach(function(item) { | ||
// html += '<li><a href="' + encodeURIComponent(item) + '">' + encodeURIComponent(item) + '</a>'; | ||
// }); | ||
// html += '<header> <h1>Node Reports</h1> </header>' | ||
// 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); | ||
// | ||
// }); | ||
// | ||
// return router; | ||
// } | ||
// |
{ | ||
"name": "heapware", | ||
"version": "1.2.2", | ||
"description": "trigger and export heap dumps rhel7 ", | ||
"version": "1.2.3", | ||
"description": "trigger and export heap-dumps and nodereport ", | ||
"main": "my-middleware.js", | ||
@@ -6,0 +6,0 @@ "bin": { |
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
33362
7
125