npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aidra/pmx

v9.48.0

Published

require('pm2')-compatible programmatic API for the pmx process manager

Readme

@aidra/pmx

A drop-in replacement for require('pm2') that drives the pmx daemon. It has no runtime dependencies and contains no daemon: it talks to $PMX_HOME/rpc.sock (RPC) and $PMX_HOME/pub.sock (event bus) using the axon-compatible wire protocol of specs/20-daemon.md §5.

const pm2 = require('@aidra/pmx'); // or: npm i pm2@npm:@aidra/pmx and keep require('pm2')

pm2.connect((err) => {
  if (err) throw err;
  pm2.start({ script: 'app.js', name: 'api', instances: 2 }, (err, procs) => {
    pm2.list((err, list) => {
      console.log(list.map((p) => `${p.name} ${p.pm2_env.status}`));
      pm2.disconnect();
    });
  });
});
  • CommonJS and ESM (import pm2 from '@aidra/pmx'); index.d.ts declares every method.
  • Callbacks only, as in pm2. pm2.promises.<method>(...) is an optional Promise façade.
  • new pm2.custom({ pm2_home, independent, daemon_mode, cwd }) creates independent instances; the PM2 home is per instance.
  • Loading the module sets process.env.PMX_PROGRAMMATIC and process.env.PM2_PROGRAMMATIC to 'true', which silences the CLI-style messages.
  • Environment variables: every setting pm2 reads as PM2_<X> (PM2_HOME, PM2_NODE, PM2_SILENT, PM2_CONCURRENT_ACTIONS, the per-file path overrides, PM2_PUBLIC_KEY, …) is also read as PMX_<X>, and the PMX_ name wins (then PM2_<X>; one warning when both are set and differ). KEYMETRICS_* and the bare PUBLIC_KEY / SECRET_KEY are no longer read (pmx 9.33). Variables the package gives the daemon and apps (PMX_HOME/PM2_HOME, the serve settings) are set under both names. The PMX_ forms need @aidra/pmx and pmx 9.33 or later. See the environment variable reference.

Daemon autostart

connect() (or any method called before connect()) first probes rpc.sock. When no daemon answers, the package starts one by running the pmx binary with its hidden daemon entry point:

<pmx binary> daemon        # env PMX_HOME=PM2_HOME=<home>, SILENT=true

The binary is located in this order:

  1. PMX_BIN — used as given;
  2. PMX_BINARY (or PM2_BINARY), then pmx on PATH, then pm2 on PATH — each only if it is a native executable that answers --version with a pmx version (9.x or later). Script files (an npm-installed Node pm2, which starts its own daemon) are never executed.

If none is found, calls that need a daemon fail with Error('pmx binary not found (set PMX_BIN or put pmx on the PATH)').

  • Daemon mode (default): the daemon is spawned detached (new session) with stdout/stderr appended to $PMX_HOME/pm2.log; the API waits until both sockets accept connections. The systemd service guard (PMX_SERVICE_GUARD=off, or PM2_SERVICE_GUARD=off, disables it) can refuse the start; the refusal is passed to the callback.
  • No-daemon mode (connect(true, cb), daemon_mode: false, independent: true): the daemon is a non-detached child with inherited stdio; it is stopped by kill()/killDaemon()/ destroy() or when the calling process exits.
  • killDaemon() installs a temporary SIGQUIT handler: the daemon signals completion with SIGQUIT to the caller's pid.

Delegated methods

Methods that are whole CLI workflows run the pmx CLI against the same PMX_HOME and map its exit status to the callback: install, uninstall, package, publish, generateModuleSample, deploy, serve, startup, uninstallStartup, logrotate, update, deepUpdate, report, generateSample, boilerplate, dockerMode, generateDockerfile, streamLogs, printLogs, pullAndReload, pullCommitId, backward, forward, link, unlink, linkManagement, openDashboard. Everything else speaks the RPC/bus protocol directly.

Tests

npm test                      # fake daemon, golden-byte framing, config handling
PMX_BIN=/path/to/pmx npm test # also runs test/real-daemon.test.js against a real daemon