DeepSeek Harness (DSH) uses a plugin-based architecture, with core logic extended through plugins. When it is necessary to restart the DS-Hns instance or the operating system, manipulating processes directly often makes it difficult to guarantee data integrity or a safe shutdown. As a DSH plugin, dsh-restart focuses on the execution layer of restarts. It is not responsible for deciding “whether” a restart is needed (that is the job of the health scheduler); instead, it ensures that the restart process complies with safety protocols such as locking, checkpoints, and graceful shutdown.
定位与职责¶
dsh-restart is an MIT-licensed plugin. Its primary responsibility is to handle the execution flow of restart requests, rather than scheduling decisions. It contains no health policies, temperature thresholds, time scheduling, or task queue access logic.
When the plugin is loaded, it publishes its restart adapter onto ctx.healthScheduler in the Harness context, allowing dsh-health-scheduler to discover and connect to it. If both are in the same profile, they can work together without writing any glue scripts.
核心功能¶
This plugin ensures restart safety through the following steps:
- Request handling: Receives and validates restart requests.
- Safety gating: Prevents concurrent restarts using an exclusive lock, and ensures the system is at a safe point through checkpoint gating.
- Ticket mechanism: Writes a ticket file containing a checksum.
- Graceful shutdown: Requests a graceful shutdown from the host.
- Observation and restart: Allows external observers to monitor the exit status and perform the restart.
安装¶
从 npm 或 tarball 安装(推荐)¶
It is recommended to use the prebuilt npm package to avoid the risk of code execution during build.
dsh plugin --profile web add dsh-restart
从 Git 安装¶
Installing from a Git repository will run npm run build, which means arbitrary code may be executed during installation. This depends on your package manager configuration (such as npm’s prepare script).
dsh plugin --profile web add github:dsh-restart/dsh-restart
使用安装脚本¶
The official PowerShell script can automatically perform registration, verification, and smoke testing.
pwsh -File scripts/install.ps1
使用 Supervisor 重启¶
dsh-restart itself does not perform the restart; instead, it delegates the restart request to an external Supervisor. The Supervisor is an independent, long-lived process that must run separately from the main DSH process so it can take over the restart after the main process exits.
The command to start the Supervisor is as follows:
node bin/supervisor.mjs --state "$env:DSH_HOME\restart" -- node dsh.js --profile web
The Supervisor is responsible for monitoring restart tickets, heartbeats, and logs, and for restarting DS-Hns after it exits.
注意事项¶
- Git installation risk: As mentioned above, Git installation triggers
npm run build. If ano lib/index.jserror appears after installation, it is usually because the package manager did not run the build script correctly. In this case, switch to npm/tarball installation or build manually. - Supervisor independence: The Supervisor must be a separate process. If it is started as a child process, it will terminate together with the DSH process, causing the restart to fail.
- Permissions and security: The plugin runs with the permissions of the current DSH process. It is recommended to review the source code and license before deployment.
总结¶
dsh-restart provides a standardized interface for the restart execution layer, decoupling the decision logic for “when to restart” from the execution logic for “how to restart.” Its worst case is that “automatic restart is unavailable,” not that the plugin itself is unavailable.
For detailed documentation and source code, see: GitHub | Plugin Catalog