cli-anything-pm2

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-anything-pm2

cli-anything-pm2

A stateless command-line interface for PM2 process management. Communicates via the PM2 CLI subprocess. No local state or session.
一款用于PM2进程管理的无状态命令行界面。通过PM2 CLI子进程进行通信,无本地状态或会话。

Installation

安装

bash
pip install -e .
Prerequisites:
  • Python 3.10+
  • PM2 installed globally (
    npm install -g pm2
    )
bash
pip install -e .
前置要求:
  • Python 3.10及以上版本
  • 全局安装PM2(执行
    npm install -g pm2

Usage

使用方法

Basic Commands

基础命令

bash
undefined
bash
undefined

Show help

显示帮助

cli-anything-pm2 --help
cli-anything-pm2 --help

Start interactive REPL mode

启动交互式REPL模式

cli-anything-pm2
cli-anything-pm2

Run with JSON output (for agent consumption)

以JSON格式输出(供Agent使用)

cli-anything-pm2 --json process list cli-anything-pm2 --json system version
undefined
cli-anything-pm2 --json process list cli-anything-pm2 --json system version
undefined

REPL Mode

REPL模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-pm2
当不指定子命令调用时,该CLI会进入交互式REPL会话:
bash
cli-anything-pm2

Enter commands interactively with tab-completion and history

可通过交互式方式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令分组

process

进程

Process inspection commands.
CommandDescription
list
List all PM2 processes
describe <name>
Get detailed info for a process
metrics
Get metrics for all processes
进程检查命令。
命令描述
list
列出所有PM2进程
describe <name>
获取指定进程的详细信息
metrics
获取所有进程的指标数据

lifecycle

生命周期

Process lifecycle commands.
CommandDescription
start <script> --name <name>
Start a new process
stop <name>
Stop a process
restart <name>
Restart a process
delete <name>
Delete a process
进程生命周期命令。
命令描述
start <script> --name <name>
启动新进程
stop <name>
停止指定进程
restart <name>
重启指定进程
delete <name>
删除指定进程

logs

日志

Log management commands.
CommandDescription
view <name> --lines 50
View recent logs
flush [name]
Flush logs
日志管理命令。
命令描述
view <name> --lines 50
查看近期日志
flush [name]
清空日志

system

系统

System-level commands.
CommandDescription
save
Save current process list
startup
Generate startup script
version
Get PM2 version
系统级命令。
命令描述
save
保存当前进程列表
startup
生成开机启动脚本
version
获取PM2版本

Output Formats

输出格式

All commands support dual output modes:
  • Human-readable (default): Tables, colors, formatted text
  • Machine-readable (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、彩色文本、格式化内容
  • 机器可读格式
    --json
    参数):供Agent使用的结构化JSON格式
bash
undefined

Human output

人类可读格式输出

cli-anything-pm2 process list
cli-anything-pm2 process list

JSON output for agents

供Agent使用的JSON格式输出

cli-anything-pm2 --json process list
undefined
cli-anything-pm2 --json process list
undefined

For AI Agents

面向AI Agent的使用说明

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
当以编程方式使用此CLI时:
  1. 始终使用
    --json
    参数
    以获得可解析的输出
  2. 检查返回码 - 0表示成功,非零表示错误
  3. 解析stderr以获取失败时的错误信息

Version

版本

1.0.0
1.0.0