Back to home

mozhi5795

dsh-kill-restart

One-click kill button for the DSH Web GUI – kill the server process without taskkill

Stars
0
Language
JavaScript
Created
Aug 15, 2026
Updated
Aug 15, 2026

Introduction

dsh-kill-restart ☠

DSH Web GUI 的一键杀死按钮。 无需 taskkill 或翻找 PID,一键终止 DSH 服务器进程,方便重启。

工作原理

  1. 一个 ☠ 骷髅按钮出现在 DSH Web GUI 右下角。
  2. 点击 → 确认弹窗。
  3. 浏览器发送 POST /api/kill-dsh
  4. 服务器先响应 { "ok": true },等 200 毫秒让浏览器收到确认,然后调用 process.exit(0)
  5. 页面显示"DSH 服务器进程已终止 — 请重启 DSH"。

安装

从 npm 安装(推荐)

dsh plugin --profile web add dsh-kill-restart

从 GitHub 安装

dsh plugin --profile web add github:mozhi5795/dsh-kill-restart

注意:Git 安装拉取的是源码而非构建产物。你必须:

  • 使用包含预构建 lib/ 文件的 tag,或
  • 在 profile 的 pnpm-workspace.yaml 中允许 prepare 脚本:
    allowBuilds:
      dsh-kill-restart: true
    

从本地目录安装

# 在包含 dsh-kill-restart 的目录中执行
dsh plugin --profile web add ./dsh-kill-restart

使用

  1. 启动包含此组合包的 DSH profile。
  2. 打开 Web GUI(默认 http://127.0.0.1:3080)。
  3. 点击右下角的 ☠ 按钮。
  4. 确认弹窗。
  5. 服务器退出,手动重启 DSH。

项目结构

dsh-kill-restart/
├── package.json          # 组合包清单(dsh.bundle + dsh.client)
├── cordis.patch.yml      # Cordis 补丁层 — 插入插件行
├── README.md             # 本文件
├── .gitignore
└── lib/
    ├── index.js          # 服务端 — POST /api/kill-dsh 路由
    └── client.js         # 客户端 — ☠ 按钮 UI

架构

这是一个 DSH 组合包(bundle) — 一个可安装的 npm 包,附带配置层。

概念文件作用
组合包清单package.json声明 dsh.bundle.patch(补丁文件)和 dsh.client(客户端模块注入)
补丁层cordis.patch.yml当 profile 列出此组合包时被插入;添加 kill-dsh-restart 插件行
服务端插件lib/index.js注入 webServer,注册 POST /api/kill-dsh,响应后调用 process.exit(0)
客户端插件lib/client.js通过 exports["./client"] 注入浏览器;添加浮动 ☠ 按钮及点击处理器

加载顺序

根据 DSH 插件开发文档, 生效配置在空根之上按以下顺序逐层组合:

  1. profile 的 bundles 列表中的各组合包补丁(按列表顺序)
  2. profile 自己的 cordis.patch.yml
  3. home 级 $DSH_HOME/cordis.patch.yml
  4. 每个 --patch <路径> 覆盖层

此组合包的补丁(cordis.patch.yml)在 profile 列出 dsh-kill-restart 时,于第 1 步被应用。

发布到 npm

此包已准备好发布到 npm:

npm login
npm publish

发布后,用户通过以下命令安装:

dsh plugin --profile web add dsh-kill-restart

开发

这是一个纯 JavaScript(ESM)插件 — 无需构建步骤。 直接在 lib/ 中编辑文件,然后用 --patch 覆盖层或 dsh plugin add ./dsh-kill-restart 本地测试。

许可证

MIT