Skip to content

Instantly share code, notes, and snippets.

@bnoguchi
Created August 5, 2010 06:04
Show Gist options
  • Save bnoguchi/509316 to your computer and use it in GitHub Desktop.
Save bnoguchi/509316 to your computer and use it in GitHub Desktop.
diff --git a/bin/nodeprofile b/bin/nodeprofile
index 608872f..9f4cba1 100755
--- a/bin/nodeprofile
+++ b/bin/nodeprofile
@@ -11,29 +11,34 @@ var command = 'node --prof --log-snapshot-positions --logfile='+logName+' '+proc
console.log('Running: '+command);
-exec(command, function (error, stdout, stderr) {
- exec('locate linux-tick-processor.py', function(err, stdout, stderr) {
- if (err) throw err;
-
- var tickLocations = stdout.trim().split('\n');
- if (tickLocations[0]) {
- exec('python '+tickLocations[0]+' '+logName, function(err, stdout, stderr) {
- console.log(stderr);
- if (!err) {
- console.log(colorFormat(stdout));
- } else {
- console.log(style(31, '\nCould not generate profile.'));
- }
-
- fs.unlink(logName, function (err) {
- if (err) throw err;
- console.log('Successfully deleted temporary: '+logName);
- });
- });
- } else {
- throw new Error('Could not find linux-tick-processor.py');
- }
- });
+//var child = exec(command, function (error, stdout, stderr) {
+//});
+exec(command).on("exit", function (code, signal) {
+ exec('locate linux-tick-processor.py', function(err, stdout, stderr) {
+ if (err) throw err;
+
+ var tickLocations = stdout.trim().split('\n');
+ if (tickLocations[0]) {
+ exec('python '+tickLocations[0]+' '+logName, function(err, stdout, stderr) {
+ console.log(stderr);
+ if (!err) {
+ fs.open("./node-profile.txt", 'w', 0666, function (err, fd) {
+ fs.write(fd, stdout, 0);
+ });
+ console.log(colorFormat(stdout));
+ } else {
+ console.log(style(31, '\nCould not generate profile.'));
+ }
+
+ fs.unlink(logName, function (err) {
+ if (err) throw err;
+ console.log('Successfully deleted temporary: '+logName);
+ });
+ });
+ } else {
+ throw new Error('Could not find linux-tick-processor.py');
+ }
+ });
});
function colorFormat(profileLog) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment