Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 6b669e7

Browse files
committed
add heapdump
1 parent db99795 commit 6b669e7

File tree

3 files changed

+76
-24
lines changed

3 files changed

+76
-24
lines changed

actions/memDump.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
3+
*
4+
* @version 1.1
5+
* @author Ghost_141
6+
* Changes in 1.1:
7+
* - Add technologies and platforms filter.
8+
*/
9+
"use strict";
10+
var heapdump = require('heapdump');
11+
12+
var async = require('async');
13+
var _ = require('underscore');
14+
var fs = require('fs');
15+
var BadRequestError = require('../errors/BadRequestError');
16+
var UnauthorizedError = require('../errors/UnauthorizedError');
17+
var ForbiddenError = require('../errors/ForbiddenError');
18+
19+
20+
exports.dumpMemory = {
21+
name: 'dumpMemory',
22+
description: 'dump memory',
23+
inputs: {
24+
required: [],
25+
optional: []
26+
},
27+
// blockedConnectionTypes: [],
28+
//outputExample: {},
29+
version: 'v2',
30+
// transaction: 'read',
31+
// databases: [],
32+
// outputExample: {
33+
// string: "hello"
34+
// },
35+
run: function (api, connection, next) {
36+
if (process.env.ADMIN_API_KEY && connection.params.apiKey === process.env.ADMIN_API_KEY) {
37+
heapdump.writeSnapshot(function(err, filename) {
38+
if (err) {
39+
connection.result = 'error: ' + err;
40+
}
41+
else {
42+
connection.result = 'dump written to: ' + filename;
43+
}
44+
next(connection, true);
45+
});
46+
} else {
47+
next(connection, true);
48+
}
49+
}
50+
};

package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,47 @@
1414
},
1515
"dependencies": {
1616
"actionhero": "8.0.x",
17-
"xml2js": "0.2.x",
17+
"adm-zip": "0.4.x",
18+
"archiver": "~0.6.1",
19+
"asn1": "*",
1820
"async": "0.2.x",
19-
"underscore": "1.5.x",
20-
"datejs": "0.0.x",
21-
"string": "1.6.x",
22-
"ldapjs": "0.7.x",
23-
"nodemailer": "0.5.x",
24-
"email-templates": "0.1.x",
2521
"bcrypt": "0.7.x",
2622
"bigdecimal": "0.6.x",
2723
"bignum": "0.6.x",
28-
"java": "0.3.x",
29-
"informix-wrapper": "git://github.com/cloudspokes/informix-wrapper.git#46d1c91c3a8e164f888e88627b8da712e9ceb855",
30-
"forums-wrapper": "git://github.com/cloudspokes/forums-wrapper.git#12b57be495c2e10431173522bc9eff60e0575959",
31-
"asn1": "*",
3224
"crypto": "0.0.x",
25+
"datejs": "0.0.x",
26+
"email-templates": "0.1.x",
27+
"forums-wrapper": "git://github.com/cloudspokes/forums-wrapper.git#12b57be495c2e10431173522bc9eff60e0575959",
28+
"heapdump": "^0.3.6",
29+
"highlight.js": ">= 8.3.0",
30+
"informix-wrapper": "git://github.com/cloudspokes/informix-wrapper.git#46d1c91c3a8e164f888e88627b8da712e9ceb855",
31+
"java": "0.3.x",
3332
"jsonwebtoken": "0.4.x",
34-
"request": "~2.33.0",
35-
"soap": "~0.3.2",
36-
"moment-timezone": "0.0.x",
37-
"moment": "~2.5.1",
33+
"ldapjs": "0.7.x",
3834
"mime": "~1.2.11",
39-
"xtend": "2.1.x",
40-
"validator": "~3.5.0",
41-
"adm-zip": "0.4.x",
4235
"mkdirp": "0.3.x",
43-
"archiver": "~0.6.1",
36+
"moment": "~2.5.1",
37+
"moment-timezone": "0.0.x",
38+
"nodemailer": "0.5.x",
4439
"redis": "0.10.x",
45-
"temp": "0.7.0",
40+
"request": "~2.33.0",
41+
"soap": "~0.3.2",
4642
"ssha": "*",
47-
"highlight.js": ">= 8.3.0",
48-
"wkhtmltoimage": ">= 0.1.3"
43+
"string": "1.6.x",
44+
"temp": "0.7.0",
45+
"underscore": "1.5.x",
46+
"validator": "~3.5.0",
47+
"wkhtmltoimage": ">= 0.1.3",
48+
"xml2js": "0.2.x",
49+
"xtend": "2.1.x"
4950
},
5051
"devDependencies": {
5152
"supertest": "0.8.x",
5253
"mocha": "1.x",
5354
"chai": "1.8.x",
5455
"fakeredis": "0.1.x",
5556
"should": ">= 3.0.0"
56-
},
57+
},
5758
"scripts": {
5859
"start": "node ./node_modules/.bin/actionhero start &",
5960
"test": "node_modules/.bin/mocha --recursive ./test",

routes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ exports.routes = {
406406
{ path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "setRoundComponents"},
407407
{ path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "setRoundTerms"},
408408
{ path: "/:apiVersion/data/srm/rounds", action: "createSRMContestRound" },
409-
{ path: "/:apiVersion/src2image", action: "convertSourceCodeToImage" }
409+
{ path: "/:apiVersion/src2image", action: "convertSourceCodeToImage" },
410+
{ path: "/:apiVersion/dump", action: "dumpMemory"}
410411
],
411412
put: [
412413

0 commit comments

Comments
 (0)