1.2.0 • Published 7 years ago

listening-processes v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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

1.2.0

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago