openclaw 网盘下载
OpenClaw

技能详情(站内镜像,无评论)

首页 > 技能库 > PM2 Process Manager

Manage Node.js applications with PM2 process manager. Use for deploying, monitoring, and auto-restarting Node apps in production. Covers starting apps, viewing logs, setting up auto-start on boot, and managing multiple processes.

开发与 DevOps

作者:Andy Steinberger @asteinberger

许可证:MIT-0

MIT-0 ·免费使用、修改和重新分发。无需归因。

版本:v1.0.0

统计:⭐ 3 · 2.8k · 3 current installs · 5 all-time installs

3

安装量(当前) 5

🛡 VirusTotal :良性 · OpenClaw :良性

Package:asteinberger/pm2

安全扫描(ClawHub)

  • VirusTotal :良性
  • OpenClaw :良性

OpenClaw 评估

This is an instruction-only skill that accurately documents standard PM2 usage; it requests no credentials or hidden installs and its instructions are proportionate to the described purpose.

目的

Name/description (manage Node.js apps with PM2) match the SKILL.md contents: npm install -g pm2 and common pm2 commands for starting, monitoring, and auto-start on boot.

说明范围

Instructions are limited to installing and using pm2 and creating an ecosystem file. They show use of environment variables (PORT) and advise running the pm2 startup command (which may require sudo). That startup step will modify system startup scripts — expected for PM2 but a privileged action the user should approve.

安装机制

No install spec in the skill bundle (instruction-only). The doc recommends npm install -g pm2 (a global npm install), which is a normal approach but will modify system/global packages and requires network access; this is expected for installing PM2.

证书

The skill does not request environment variables, secrets, or config paths. Example usage shows typical NODE_ENV/PORT settings but no unexplained credential or cross-service access.

持久

The documented commands (pm2 save, pm2 startup) create persistent background services and startup scripts. Those are legitimate for a process manager but are persistent, system-level changes that require user/admin consent (sudo).

综合结论

This skill is an instruction-only guide for PM2 and is internally consistent. It does not ask for secrets or install code itself, but following the steps will install PM2 globally and may require sudo to register startup scripts. Only proceed if you trust running global npm installs on this machine and understand that pm2 startup + pm2 save will create persistent services and modify system startup. Prefer running installs as the intended user …

安装(复制给龙虾 AI)

将下方整段复制到龙虾中文库对话中,由龙虾按 SKILL.md 完成安装。

请把本段交给龙虾中文库(龙虾 AI)执行:为本机安装 OpenClaw 技能「PM2 Process Manager」。简介:Manage Node.js applications with PM2 process manager. Use for deploying, monito…。
请 fetch 以下地址读取 SKILL.md 并按文档完成安装:https://raw.githubusercontent.com/openclaw/skills/refs/heads/main/skills/asteinberger/pm2/SKILL.md
(来源:yingzhi8.cn 技能库)

SKILL.md

打开原始 SKILL.md(GitHub raw)

---
name: pm2
description: Manage Node.js applications with PM2 process manager. Use for deploying, monitoring, and auto-restarting Node apps in production. Covers starting apps, viewing logs, setting up auto-start on boot, and managing multiple processes.
---

# PM2 Process Manager

Production process manager for Node.js with built-in load balancer.

## Install

```bash
npm install -g pm2
```

## Quick Start

```bash
# Start an app
pm2 start app.js
pm2 start npm --name "my-app" -- start
pm2 start "npm run start" --name my-app

# With specific port/env
pm2 start npm --name "my-app" -- start -- --port 3000
PORT=3000 pm2 start npm --name "my-app" -- start
```

## Common Commands

```bash
# List processes
pm2 list
pm2 ls

# Logs
pm2 logs              # All logs
pm2 logs my-app       # Specific app
pm2 logs --lines 100  # Last 100 lines

# Control
pm2 restart my-app
pm2 stop my-app
pm2 delete my-app
pm2 reload my-app     # Zero-downtime reload

# Info
pm2 show my-app
pm2 monit             # Real-time monitor
```

## Auto-Start on Boot

```bash
# Save current process list
pm2 save

# Generate startup script (run the output command with sudo)
pm2 startup

# Example output - run this:
# sudo env PATH=$PATH:/opt/homebrew/bin pm2 startup launchd -u username --hp /Users/username
```

## Next.js / Production Builds

```bash
# Build first
npm run build

# Start production server
pm2 start npm --name "my-app" -- start

# Or with ecosystem file
pm2 start ecosystem.config.js
```

## Ecosystem File (ecosystem.config.js)

```javascript
module.exports = {
  apps: [{
    name: 'my-app',
    script: 'npm',
    args: 'start',
    cwd: '/path/to/app',
    env: {
      NODE_ENV: 'production',
      PORT: 3000
    }
  }]
}
```

## Useful Flags

| Flag | Description |
|------|-------------|
| `--name` | Process name |
| `--watch` | Restart on file changes |
| `-i max` | Cluster mode (all CPUs) |
| `--max-memory-restart 200M` | Auto-restart on memory limit |
| `--cron "0 * * * *"` | Scheduled restart |

## Cleanup

```bash
pm2 delete all        # Remove all processes
pm2 kill              # Kill PM2 daemon
pm2 unstartup         # Remove startup script
```