diff --git a/actions/memDump.js b/actions/memDump.js new file mode 100644 index 000000000..7a78211c5 --- /dev/null +++ b/actions/memDump.js @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2014 TopCoder Inc., All Rights Reserved. + */ +"use strict"; +var heapdump = require('heapdump'); + +exports.dumpMemory = { + name: 'dumpMemory', + description: 'dump memory', + inputs: { + required: [], + optional: [] + }, + version: 'v2', + run: function (api, connection, next) { + if (process.env.ADMIN_API_KEY && connection.params.apiKey === process.env.ADMIN_API_KEY) { + heapdump.writeSnapshot(function(err, filename) { + if (err) { + connection.result = 'error: ' + err; + } + else { + connection.result = 'dump written to: ' + filename; + } + next(connection, true); + }); + } else { + next(connection, true); + } + } +}; diff --git a/package.json b/package.json index a4108c194..0bfb2c5da 100644 --- a/package.json +++ b/package.json @@ -14,38 +14,39 @@ }, "dependencies": { "actionhero": "8.0.x", - "xml2js": "0.2.x", + "adm-zip": "0.4.x", + "archiver": "~0.6.1", + "asn1": "*", "async": "0.2.x", - "underscore": "1.5.x", - "datejs": "0.0.x", - "string": "1.6.x", - "ldapjs": "0.7.x", - "nodemailer": "0.5.x", - "email-templates": "0.1.x", "bcrypt": "0.7.x", "bigdecimal": "0.6.x", "bignum": "0.6.x", - "java": "0.3.x", - "informix-wrapper": "git://github.com/cloudspokes/informix-wrapper.git#46d1c91c3a8e164f888e88627b8da712e9ceb855", - "forums-wrapper": "git://github.com/cloudspokes/forums-wrapper.git#12b57be495c2e10431173522bc9eff60e0575959", - "asn1": "*", "crypto": "0.0.x", + "datejs": "0.0.x", + "email-templates": "0.1.x", + "forums-wrapper": "git://github.com/cloudspokes/forums-wrapper.git#12b57be495c2e10431173522bc9eff60e0575959", + "heapdump": "^0.3.6", + "highlight.js": ">= 8.3.0", + "informix-wrapper": "git://github.com/cloudspokes/informix-wrapper.git#46d1c91c3a8e164f888e88627b8da712e9ceb855", + "java": "0.3.x", "jsonwebtoken": "0.4.x", - "request": "~2.33.0", - "soap": "~0.3.2", - "moment-timezone": "0.0.x", - "moment": "~2.5.1", + "ldapjs": "0.7.x", "mime": "~1.2.11", - "xtend": "2.1.x", - "validator": "~3.5.0", - "adm-zip": "0.4.x", "mkdirp": "0.3.x", - "archiver": "~0.6.1", + "moment": "~2.5.1", + "moment-timezone": "0.0.x", + "nodemailer": "0.5.x", "redis": "0.10.x", - "temp": "0.7.0", + "request": "~2.33.0", + "soap": "~0.3.2", "ssha": "*", - "highlight.js": ">= 8.3.0", - "wkhtmltoimage": ">= 0.1.3" + "string": "1.6.x", + "temp": "0.7.0", + "underscore": "1.5.x", + "validator": "~3.5.0", + "wkhtmltoimage": ">= 0.1.3", + "xml2js": "0.2.x", + "xtend": "2.1.x" }, "devDependencies": { "supertest": "0.8.x", @@ -53,7 +54,7 @@ "chai": "1.8.x", "fakeredis": "0.1.x", "should": ">= 3.0.0" - }, + }, "scripts": { "start": "node ./node_modules/.bin/actionhero start &", "test": "node_modules/.bin/mocha --recursive ./test", diff --git a/routes.js b/routes.js index 62ee700f4..e9d94651f 100755 --- a/routes.js +++ b/routes.js @@ -406,7 +406,8 @@ exports.routes = { { path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "setRoundComponents"}, { path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "setRoundTerms"}, { path: "/:apiVersion/data/srm/rounds", action: "createSRMContestRound" }, - { path: "/:apiVersion/src2image", action: "convertSourceCodeToImage" } + { path: "/:apiVersion/src2image", action: "convertSourceCodeToImage" }, + { path: "/:apiVersion/dump", action: "dumpMemory"} ], put: [