Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to get the list of process

how to get the list of process

Problem

I am playing around with node and just installed it on my Machine. Now I want to get a list of processes running on my machine so I can see if apache is running and if mysql is started etc? how can I do that. I just have very basic code in my js file. I dont even know where to begin on this here is my code

var http = require('http');
http.createServer(function(request, response){
    response.writeHead(200);
    response.write("Hello world");
    console.log('Listenning on port 1339');
    response.end();


}).listen(8080);

Thanks

Problem courtesy of: Autolycus

Solution

As far as I know there isn't a module (yet) to do this cross-platform. You can use the child process API to launch tools that will give the data you want. For Windows, just launch the built-in tasklist process.

var exec = require('child_process').exec;
exec('tasklist', function(err, stdout, stderr) {
  // stdout is a string containing the output of the command.
  // parse it and look for the apache and mysql processes.
});
Solution courtesy of: The Reddest

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

how to get the list of process

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×