target 命令

目录

  1. 简介
  2. 命令格式
  3. 子命令
  4. 示例
  5. current 退出码
  6. 版本历史
  7. 相关命令

简介

target 命令用于管理 Peeka target agent:发现当前主机上的 Peeka 目标、查看状态、清理 stale marker,并按 target ID 分离目标。它是其他诊断命令的前置入口——只有先确认 target 处于 alive 状态,watchtraceinspect 等命令才能正确路由到目标进程。

通过 listcurrentstatusinspectcleanupdetach 子命令可以在多 target 共存的场景中精确指定操作对象,并及时回收已退出但 socket marker 仍残留的 stale target。

命令格式

peeka-cli target <subcommand> [options]

target 面向已经被 Peeka 注入或管理的目标进程。目标状态包括 alivestaleunknownattachingfaileddetached

session 是兼容旧脚本的弃用别名:

peeka-cli session list

新脚本请改用 peeka-cli target ...

子命令

子命令 说明
list 列出发现的 target agent
current 当且仅当存在一个 alive target 时返回当前 target
status --target <id> 查看指定 target 的摘要状态
inspect --target <id> 查看指定 target 的完整详情、能力和下一步动作
cleanup [--target <id>] [--dry-run] 清理 stale target marker;默认只清理 stale target
detach --target <id> [--force] 分离指定 target;alive target 需要 --force

所有子命令都支持:

参数 说明
--format table 默认表格输出
--format json 输出 JSONL 事件,便于脚本处理

示例

# 列出所有 target
peeka-cli target list

# 机器上只有一个 alive target 时返回它
peeka-cli target current

# 查看详情
peeka-cli target inspect --target target_abcd1234 --format json

# 预览 stale marker 清理
peeka-cli target cleanup --dry-run

# 分离 alive target
peeka-cli target detach --target target_abcd1234 --force

current 退出码

退出码 含义
0 恰好存在一个 alive target
1 没有 alive target
2 存在多个 alive target,需要显式选择

版本历史

版本 发布日期 变更说明
0.1.16 2026-06-07 新增 target 命令组;session 作为弃用兼容别名保留

相关命令

  • attach - 附加到目标进程
  • detach - 分离当前会话
  • client - 管理客户端会话

回到顶部

Copyright © 2026 Peeka contributors. Distributed under the Apache License 2.0.

This site uses Just the Docs, a documentation theme for Jekyll.