Skip to content

A simple NPM module for retrieving pertinent info on processes which are listening on local ports, and for killing those processes using shell commands `lsof`, `ps`, and `kill` in the background.

Notifications You must be signed in to change notification settings

matthewgonzalez/listening-processes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

listening-processes Build Status

"A simple NPM module for retrieving pertinent info on processes which are listening on local ports, and for killing those processes using shell commands lsof, ps, and kill in the background."

Install

$ npm install --save listening-processes

Usage

const processes = require('listening-processes')

processes(['node', 'ruby'])  // returns object of all Listening Processes for each command in array

  /* Object output resembles the following:
    {
      node: [
        { command: 'node',
          pid: '581',
          port: '20559',
          invokingCommand: 'pow' },
        { command: 'node',
          pid: '642',
          port: '4200',
          invokingCommand: 'ember server' }
      ],
      ruby: [
        { command: 'ruby',
          pid: '720',
          port: '3000',
          invokingCommand: 'rails s'
        }
      ]
    }
  */
processes('node') // same as above but returns results for the single command
processes() // same as above but returns all listening processes

processes.kill('581') // kills process at PID=581
  /*
    The `kill` method returns an object with two arrays, 'success' & 'fail', which include the PIDs of the respective results.

    Example:
    {
      success: [720, 642],
      fail: [581]
    }
  */
processes.kill(720)
processes.kill(['581', '642']) // kills processes at all PIDs in the array
processes.kill([720, 581])

License

MIT © Matthew Gonzalez

About

A simple NPM module for retrieving pertinent info on processes which are listening on local ports, and for killing those processes using shell commands `lsof`, `ps`, and `kill` in the background.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published