1.0.1 • Published 6 years ago

porthog v1.0.1

Weekly downloads
12
License
MIT
Repository
github
Last release
6 years ago

porthog

This module identifies which application is using a specified port, providing the process name and PID. Works for Windows, OSX, and most flavors of Linux/Unix that support the lsof, ss, or netstat operations.

CLI Implementation

npm install -g porthog

porthog 33649 80

Outputs:

PORT      PID       PROCESS
--------------------------------------------------
33649     43580     node-webkit Helper (cbutler)
80        -         -

API Implementation Example

const porthog = require('porthog')
const data = porthog(80)

console.log(data.user, 'is running', data.process + ' (PID ' + data.pid + ') on port 80.')

// Output
// cbutler is running node.exe (PID 656) on port 80.

This operation may require elevated/root privileges.

Uses

We're using this in Fenix Web Server to resolve port conflicts. When a user tries to launch a server on an occupied port, we use porthog to determine which app is "hogging" the port and provide the user an option to stop/kill the offending process.

We also use this in combination with node-windows, node-mac, and node-linux to create background processes that monitor ports and notify users what's running on the ports they want to use.

There are certainly many other uses. If you use this, be warned that some operating systems (Windows in particular) may require elevated permissions. This is dependent on each user's environment, so it's not always predictable. To get around this, we've found the aforementioned node-* modules to be useful when creating daemons (especially the binary utilities and extra scripts for Windows). For Electron/NW.js apps, sudo-prompt has been quite helpful.

License

MIT

1.0.1

6 years ago

1.0.0

6 years ago

0.0.8

6 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago