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

process-guard

v1.0.0

Published

Ultra-lightweight process manager with auto-restart, real-time monitoring, multi-channel notifications, live dashboard, and cloud sync — the PM2 alternative that just works.

Downloads

156

Readme

🛡️ process-guard

Ultra-lightweight process manager with auto-restart, real-time monitoring,
multi-channel notifications, live dashboard, and optional cloud sync.

npm version License: MIT Node.js

"One command. Your server never sleeps again."


Why process-guard?

Your server crashed at 4 AM. You slept. Your users didn't.
PM2 is powerful — but overkill for most projects and hard to learn.
process-guard gives you what you actually need in one command:

npx process-guard node server.js --restart --notify telegram --token BOT_TOKEN --chat-id CHAT_ID

✅ Auto-restart on crash
✅ Memory & CPU monitoring
✅ Telegram / Slack / Discord / Email alerts
✅ Beautiful live dashboard
✅ Zero config needed


Installation

npm install -g process-guard   # global CLI
npm install process-guard      # project dependency

Quick Start

# Auto-restart only
npx process-guard node server.js --restart

# + Telegram alerts
npx process-guard node app.js \
  --restart \
  --notify telegram \
  --token YOUR_BOT_TOKEN \
  --chat-id YOUR_CHAT_ID

# + Live dashboard
npx process-guard node app.js \
  --restart --dashboard --dashboard-port 9000

# Full setup
npx process-guard node server.js \
  --restart \
  --notify slack --token WEBHOOK_URL \
  --dashboard --dashboard-port 9000 \
  --max-memory 512 --max-cpu 85

CLI Options

Usage: process-guard <command> [options]

Options:
  -r, --restart               Enable automatic restart on crash
  --strategy <name>           exponential | fixed | linear | immediate  (default: exponential)
  --restart-delay <ms>        Base restart delay  (default: 1000)
  --max-restarts <n>          Max restart attempts per hour  (default: 10)

  --max-memory <mb>           Memory threshold in MB  (default: 512)
  --max-cpu <pct>             CPU threshold in %  (default: 90)
  --check-interval <ms>       Polling interval  (default: 5000)

  -n, --notify <channel>      telegram | slack | discord | email
  -t, --token <value>         Bot token or Webhook URL
  --chat-id <id>              Telegram chat ID
  --notify-level <level>      Minimum notification level  (default: warning)

  -d, --dashboard             Enable live web dashboard
  -p, --dashboard-port <port> Dashboard port  (default: 9000)
  --dashboard-password <pass> Protect dashboard with a password

  --cloud-key <key>           process-guard cloud API key
  --log-level <level>         debug | info | warning | error  (default: info)
  --log-json                  Output JSON logs
  --no-color                  Disable colour output

  -v, --version               Print version
  -h, --help                  Show this help

Programmatic API

const ProcessGuard = require('process-guard');

const guard = new ProcessGuard('node server.js', {
  restart: {
    enabled    : true,
    strategy   : 'exponential',
    maxRestarts: 10,
  },
  monitor: {
    memoryThreshold: 512,   // MB
    cpuThreshold   : 85,    // %
  },
  notifications: {
    enabled : true,
    minLevel: 'warning',
    telegram: {
      botToken: process.env.TELEGRAM_TOKEN,
      chatId  : process.env.TELEGRAM_CHAT_ID,
    },
  },
  dashboard: { enabled: true, port: 9000 },
});

guard.on('crash',              (e)   => console.log('Crash!', e));
guard.on('memory-warning',     ({ value }) => console.log(`Memory: ${value}MB`));
guard.on('max-restarts-exceeded', () => process.exit(4));

await guard.start();

Live Dashboard

Open http://localhost:9000 after enabling --dashboard.

Features:

  • Real-time memory & CPU charts (WebSocket-powered)
  • Process status, PID, uptime, restart count
  • Error / warning event log
  • Memory leak detector
  • One-click restart & stop

Notification Channels

| Channel | Setup | |---------|-------| | Telegram | Create a bot with @BotFather, copy token + chat_id | | Slack | Create an Incoming Webhook in your workspace | | Discord | Server → Integrations → Webhooks → Create | | Email | Any SMTP server (Gmail, SendGrid, Mailgun, …) |


Project Structure

process-guard/
├── bin/process-guard.js        # CLI entry point
├── src/
│   ├── index.js                # Main ProcessGuard class
│   ├── core/
│   │   ├── ProcessManager.js   # Spawn, I/O, lifecycle
│   │   ├── Monitor.js          # CPU & memory polling
│   │   ├── Restart.js          # Smart restart policies
│   │   └── Detector.js         # Pattern-based crash detection
│   ├── notifiers/
│   │   ├── NotifierBase.js     # Base class (retry, rate-limit)
│   │   ├── TelegramNotifier.js
│   │   ├── SlackNotifier.js
│   │   ├── DiscordNotifier.js
│   │   └── EmailNotifier.js
│   ├── metrics/
│   │   ├── MetricsCollector.js # Orchestrator
│   │   ├── MemoryTracker.js    # Leak detection
│   │   ├── CPUTracker.js       # Spike detection + P95
│   │   └── StorageManager.js   # NDJSON persistence
│   ├── dashboard/
│   │   ├── DashboardServer.js  # Express + WebSocket server
│   │   ├── api/routes.js       # REST endpoints
│   │   ├── api/middleware.js   # Auth + CORS
│   │   └── assets/             # HTML / CSS / JS (no build step)
│   ├── cloud/
│   │   ├── CloudClient.js      # HTTP client
│   │   ├── Auth.js             # JWT auth
│   │   └── Sync.js             # Background sync loop
│   ├── config/
│   │   ├── DefaultConfig.js
│   │   ├── ConfigParser.js     # File + env-var resolution
│   │   └── validators.js
│   └── utils/
│       ├── Logger.js           # Levelled, coloured logger
│       ├── helpers.js
│       └── constants.js
├── examples/                   # Runnable examples
├── tests/                      # Jest unit + integration tests
└── docs/                       # Full documentation

Documentation

| Guide | Description | |-------|-------------| | Getting Started | Installation & quick start | | Configuration | All options explained | | Notifiers | Set up Telegram, Slack, Discord, Email | | Dashboard | Live web dashboard guide | | API Reference | Programmatic API & events | | Cloud Service | Remote monitoring ($8/mo) | | Troubleshooting | Common issues & fixes |


License

MIT — free for personal and commercial use.