360 Secure SkillHub
360 安全技能中心

ProcessGuard — Critical Process Monitor & Auto-Restart

面向 Node.js 的进程守护工具:可用 HTTP、TCP 端口、PID 文件或 shell 命令做健康检查,进程失败后按重试上限与冷却时间自动重启;支持 CPU 与内存阈值监控(需可选安装 pidusage),告警按 warning→critical 经回调、Webhook 或 JSON 文件升级,并提供心跳文件与可选 HTTP 状态面板。

theshadowrose
theshadowrose
热度 87.67
最近更新 2026-05-17 14:07:50
分类:自动化依赖:代码执行 / 读写文件 / 第三方 API应用场景:DevOps / 自动化脚本 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add process-guard
Metadata
name
ProcessGuard — Critical Process Monitor & Auto-Restart
description
Monitor critical processes and auto-restart on failure. Tracks CPU and memory usage, escalates alerts via webhook, callback, or file, and writes a dead man's switch heartbeat so you know if ProcessGuard itself goes down. HTTP dashboard included. Zero required dependencies — CPU/memory monitoring unlocked with optional pidusage install.
author
@TheShadowRose
version
2.1.4
tags
["process-guard","monitor","auto-restart","uptime","devops"]
license
MIT

ProcessGuard — Critical Process Monitor & Auto-Restart

Keep services running without babysitting. Define processes, configure health checks, and let ProcessGuard handle the rest.

What It Does

  • Health checks — HTTP, TCP port, PID file, or shell command
  • Auto-restart — configurable retry limits and cooldown delays
  • CPU & memory monitoring — per-process thresholds with alerts (requires npm install pidusage)
  • Alert escalation — warning → critical, delivered via callback / webhook / JSON file
  • Dead man's switch — heartbeat file updated every 10s so external monitors know if ProcessGuard itself crashes
  • HTTP dashboard — optional /status endpoint for real-time JSON status
  • Command allowlist — optionally restrict which executables restart/check commands may use

Quick Setup

const { ProcessGuard } = require('./src/process-guard');

const guard = new ProcessGuard({
  processes: [
    {
      name: 'ollama',
      check: 'http://localhost:11434/api/tags',
      restart: 'ollama serve',
      maxRestarts: 5,
      cooldown: 5000
    }
  ],
  checkInterval: 30000,
  dashboardPort: 9090,
  alert: {
    onAlert: async (alert) => console.error(`ALERT: ${alert.message}`)
  }
});

guard.start();

See README.md for full documentation, all config options, and advanced examples.