listening-processes
"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
, andkill
in the background."
Install
$ npm install --save listening-processes
Usage
const processes = // 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' } ] } */ // same as above but returns results for the single command // same as above but returns all listening processes processes // 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] } */processesprocesses // kills processes at all PIDs in the arrayprocesses
License
MIT © Matthew Gonzalez