New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

manager-process

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

manager-process

Gets the manager process in a multi-processing application.

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

Manager Process

In multi-processing scenario, it's better to handle some operations in just one process, rather than repeatedly running them in all processes. If you you have all control of the master process, you can just put the code in the master process. However, you don't have control, e.g. using PM2, you need a way to find out which process should run the specific program. Such a process, I call it the Manager process.

Example

const manager = require("manager-process");

(async () => {
    var _manager = await manager.getManager();
    var processes = await manager.getAllProcesses();
    var pid = await manager.getManagerPid();
    var isManager = await manager.isManager();

    if (isManager) {
        // TODO...
    }

    // This is the same
    if (pid === process.pid) {
        // TODO...
    }

    console.log(_manager);
    // {
    //  pid: number,
    //  ppid?: number,
    //  uid?: number;
    //  gid?: number;
    //  name: string;
    //  cmd: string;
    // }

    console.log(processes);
    // Array<{
    //  pid: number,
    //  ppid?: number,
    //  uid?: number;
    //  gid?: number;
    //  name: string;
    //  cmd: string;
    // }>
})();

Keywords

multi-processing

FAQs

Package last updated on 29 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts