Introduction¶
The philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” During local development or debugging, if the dsh agent runs inside the web service process, killing the web process directly via a command (such as Stop-Process) is equivalent to killing the process tree in which the agent resides. This prevents the restart command from executing and causes a “suicide-style restart” problem.
dsh-web-restart creates a new service process under the WMI host through WMI (Win32_Process.Create), fully detaching it from the agent process tree. When this plugin is loaded, the service is automatically restarted if it goes down; when new code needs to be loaded, a flag can be used to trigger a detached restart.
What Is This¶
This is a DSH bundle plugin used to ensure or restart the DeepSeek Harness web service. It is maintained by LnsiAxe and licensed under the MIT License.
Installation and Enablement¶
Before installing, make sure that the DSH version is 0.1.0-rc.6 or higher.
# 在 headless profile 下安装,用于服务挂了时通过任务复活 web 服务
dsh plugin --profile headless add @lnsiaxe/dsh-web-restart
# 在 web profile 下安装,用于启用 flag 文件触发重启功能
dsh plugin --profile web add @lnsiaxe/dsh-web-restart
# 启动 dsh web,插件会在加载时生效
dsh web
Core Features¶
This plugin provides two operational modes and one triggering mechanism:
- ensure mode (default): Checks whether the port is listening. If it is not listening, it starts the service in detached mode; if it is listening, it does nothing.
- rotate mode: Checks whether the port is listening. If it is listening, it performs a detached restart (killing the service after the caller returns and then starting it again); if it is not listening, it starts the service directly.
- flag file trigger: When running under the web profile, create a specific flag file. At the beginning of the next conversation turn, the plugin deletes the flag file and restarts the service in detached mode.
Typical Usage¶
Scenario 1: After the Service Goes Down
# 运行 headless 任务,插件会在 boot 时自动拉起 web 服务
dsh --profile headless "启动 web 服务"
Scenario 2: Restart After Loading New Code
# 1. 在 web profile 下创建 flag 文件
New-Item C:\Users\<you>\.dsh\dsh-web-restart.flag
# 2. 发送一条消息触发新回合
# 插件检测到 flag,删除 flag 并重启 web 服务
Configuration¶
Configure the port and mode via cordis.patch.yml:
- insert:
- id: web-restart
name: '@lnsiaxe/dsh-web-restart'
config:
port: 3080 # web 服务端口
mode: ensure # ensure | rotate
# workspace: C:\Users\<you>\my-workspace # 可选,默认取进程 cwd
# gitDir: C:\Users\<you>\git\cmd # 可选,默认 ~\git\cmd(给 side-panel 的 git 用)
How It Works¶
- Script generation: When activated, the plugin generates
dsh-web-restart-launch.cmdanddsh-web-restart-rotate.cmdunder theDSH_HOMEdirectory. These scripts are responsible for setting environment variables, changing directories, and executingnode ... web --port <port>. - Process startup: WMI is invoked through PowerShell’s
Invoke-CimMethod Win32_Process.Create. On Windows platforms, the parent process of the new process is the WMI host, so it is not affected by cleanup of the agent/service process tree; on non-Windows platforms, it falls back tospawn(..., { detached: true }).unref(). - Avoiding self-restart: When loaded under the web profile, the plugin checks whether
argvcontainsweb. If it does, it skips its self-restart logic and only responds to flag file triggers.
Notes¶
- Platform dependency: Windows platforms depend on WMI; non-Windows platforms use detached
spawn. - Version requirement: DSH version
0.1.0-rc.6or higher is required. - Permission and security: The plugin runs with the permissions of the current
dshprocess. Please review the source code and license before use.