1.4.7 • Published 2 years ago

find-process v1.4.7

Weekly downloads
521,461
License
MIT
Repository
github
Last release
2 years ago

find-process Build Status js-standard-style

With find-process, you can:

  • find the process which is listening specified port
  • find the process by pid
  • find the process by given name or name pattern

We have covered the difference of main OS platform, including Mac OSX, Linux, Windows and Android (with Termux).

CLI

Install find-process as a CLI tool:

$ npm install find-process -g

Usage:

  Usage: find-process [options] <keyword>


  Options:

    -V, --version      output the version number
    -t, --type <type>  find process by keyword type (pid|port|name)
    -p, --port         find process by port
    -h, --help         output usage information

  Examples:

    $ find-process node          # find by name "node"
    $ find-process 111           # find by pid "111"
    $ find-process -p 80         # find by port "80"
    $ find-process -t port 80    # find by port "80"

Example:

image

Node API

You can use npm to install:

$ npm install find-process --save

Usage:

const find = require('find-process');

find('pid', 12345)
  .then(function (list) {
    console.log(list);
  }, function (err) {
    console.log(err.stack || err);
  })

Synopsis

Promise<Array> find(type, value, [strict])

Arguments

  • type the type of find, support: port|pid|name
  • value the value of type, can be RegExp if type is name
  • strict the optional strict mode is for checking port, pid, or name exactly matches the given one. (on Windows, .exe can be omitted)

Return

The return value of find-process is Promise, if you use co you can use yield find(type, value) directly.

The resolved value of promise is an array list of process ([] means it may be missing on some platforms):

[{
  pid: <process id>,
  ppid: [parent process id],
  uid: [user id (for *nix)],
  gid: [user group id (for *nix)],
  name: <command/process name>,
  bin: <execute path (for *nix)>,
  cmd: <full command with args>
}, ...]

Example

Find process which is listening port 80.

const find = require('find-process');

find('port', 80)
  .then(function (list) {
    if (!list.length) {
      console.log('port 80 is free now');
    } else {
      console.log('%s is listening port 80', list[0].name);
    }
  })

Find process by pid.

const find = require('find-process');

find('pid', 12345)
  .then(function (list) {
    console.log(list);
  }, function (err) {
    console.log(err.stack || err);
  });

Find all nginx process.

const find = require('find-process');

find('name', 'nginx', true)
  .then(function (list) {
    console.log('there are %s nginx process(es)', list.length);
  });

Contributing

We're welcome to receive Pull Request of bugfix or new feature, but please check the list before sending PR:

  • Coding Style Please follow the Standard Style
  • Documentation Add documentation for every API change
  • Unit test Please add unit test for bugfix or new feature

License

MIT

@dysolix/hasagichrome-devtools-devicespioneer-cosmos-tx-ingesterdiscord-self-bots-ez@dxos/xbox-dashboardmenlolab-runner@honeyworks/holochain-corecopydistpdxdeploy-v3.1.3@byteinspire/cli@infinitebrahmanuniverse/nolb-findopensea-submarine-v2git-repo-blog-generator@everything-registry/sub-chunk-1669@fed123/fe-plugin-monitoryio-coreyaml2solana@e11/libraries@editframe/editframe-jswebpack-port-collectortor-mgrtoad-serverturbowatchtyzxbszionbox-desktopzionbox-mirrorzionbox-servicevite-postgresvisopvcr-cli@hankts/shopify-cli-kit@hashed-alejandro/afloat-client@itayn-fireberry-org/itayn-testtailchat-cli@guseyn/cutie-process@gswl/startuppwa-asset-generatorpwa-asset-generator-fix-chromiumdelectusquoqute-cli-coredevspacedevtools-fmdllc-clireflect-nexusremote-workspacerearguardreplayiorichangrocket-sleds2client-api-typescriptsecondstep-marketingselenium-standalonesakkeshibarium-bridgesnailycad-managersourcescapespok@monesign/aragen@mina-tools/cli@mina-tools/core@lightprotocol/cli@matvp91/webrun@mashroom/mashroom-utils@langhuihui/monica@lanz1/v-money3@laraboot-io/cli@mikojs/worker@microsoft/inshellisense@owlworks/composer-extension-bot-publish@pact-toolbox/utils@morpheusnetwork/trustmnw-cli@morpheusnetwork/trustmnw-cli-dev@mozilla/jest-dev-server@gaarutyunov/pwa-asset-generator@fdnpm/fd-module-cli@pfapi/utils@perspect3vism/ad4m-test@hotfusion/gateway@pittankopta/vibraniumnode-test-servercompilescustomdiscord-installerplaycanvas-syncpm2-agent-monitoringcoattailcompagnon-uninstallerotel-clipidifypidmanpdxdeploypico-toolscross-toolsdashcamdockerappmanagerpayara-scriptcrrp-launchersdk-core@mgutz/task@provenanceio/cavendish@pipcook/pipcook-cli
1.4.6

2 years ago

1.4.7

2 years ago

1.4.5

3 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago