1.0.1 • Published 5 years ago

is-master-process v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

is-master-process NPM version NPM monthly downloads NPM total downloads

Returns true if current process is master when running Node app in cluster mode.

Install

Install with npm:

$ npm install --save is-master-process

Why is this needed?

While Node's cluster API offers a simple way to check if a process is master, there are instances where you won't directly call the API. For example, if running in cluster mode in PM2.

This module helps identify the master process in one line of code.

Usage

const isMasterProcess = require('is-master-process')

if (isMasterProcess) {
  console.log('PID:', process.pid, 'is master')
}