DeepSeek Harness plugin

dsh-port-guard

Triage port conflicts: reuse your own live server, switch ports for others, precisely kill zombies

Jump to install

Source facts

Repository
PangYiMing/dsh-port-guard
Latest update
Aug 13, 2026
Category
Security & Permissions
GitHub stars
1
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/PangYiMing/dsh-port-guard
Plugin: dsh-port-guard
Author: PangYiMing

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-port-guard

> DeepSeek Harness 插件 · 端口占用处置 / DSH plugin for triaging port conflicts

dev server 启动报 EADDRINUSE: address already in use——最常见的前置障碍。但不是所有 EADDRINUSE 都该 kill

The classic blocker before any dev server starts. But not every EADDRINUSE should be killed.

核心洞察:EADDRINUSE 有三条路,不是只有"杀"

情况占端口的是谁正确动作
A. 自己的、还在正常服务的 dev server上次会话遗留的同项目 dev server复用,比重启快
B. 别人的项目 / 不该杀的进程另一个项目 / 系统服务换端口绕开,不抢杀
C. 确认是僵尸/残留进程已死但端口没释放 / 重复拉起的精确 PID kill

先判断属于哪种,再决定动作。不无脑 kill。

定位 + 取证 Identify & investigate

./scripts/port-guard.sh 8080

脚本会打印占用进程的完整身份信息:

# 定位
lsof -nP -iTCP:8080 -sTCP:LISTEN
# 身份:启动时刻/运行时长/有无控制终端
ps -o pid,ppid,lstart,etime,tty,%cpu,rss,command -p "$PID"
# 工作目录 → 属于哪个项目
lsof -a -p "$PID" -d cwd -Fn | grep '^n' | sed 's/^n//'
# 子进程(有子进程的别直接杀父,先看树)
pgrep -P "$PID"

判读组合

观察含义
PPID=1父进程已退出,被 launchd 收养 —— 孤儿
tty=??没有控制终端,不是人在终端里跑的
fd0 → /dev/nullfd1/fd2 → 某个 .lognohup cmd > log 2>&1 & 指纹 → agent/脚本起的
tty=ttys00X人在终端窗口起的,杀之前更该问一声
etime 好几天 + %cpu 0.0 + rss 极小挂了很久的僵尸 watcher(可能 watch 源码目录,某天突然醒来写产物)

三种处置 Three paths

# A. 复用:确认进程还活着(kill -0 只检测不杀)
kill -0 "$PID" && echo alive

# B. 换端口绕开,不杀别人的
PORT=18080 node index.js

# C. 精确 kill(先 SIGTERM 给优雅退出机会,不行再 SIGKILL)
./scripts/port-guard.sh 8080 --kill

安全红线 Safety rules

1. 先判断该不该杀——EADDRINUSE 不等于该杀(复用 > 重启)。 2. 绝不 killall node / pkill -f node——精确 PID,不误伤其他正常服务。 3. PID < 100 绝不杀——系统进程。 4. 别人的进程不杀——换端口绕开。 5. 命令行看不懂 / 不确定是什么——停下报告用户,不擅自杀。

安装 Install

# 发布到 npm 后
dsh plugin --profile demo add dsh-port-guard

# 或从 GitHub 安装
dsh plugin --profile demo add github:PangYiMing/dsh-port-guard

许可证 License

[MIT](./LICENSE)