When developing agents or adjusting configurations, restarting the service is required after modifying a bundle, plugin, or theme. Manual operations rely on the desktop launcher, and inconsistent paths or startup arguments can cause environment differences. This plugin adds a “Restart Web Service” button in the General section of the DSH settings page, directly reusing the configuration of the currently running process to restart, and the page automatically reloads after the service is ready.
dsh-restart-btn is a DSH plugin maintained by SiriusWJ. It reuses the desktop launcher mechanism (node + lib/bin.js, log redirection, and TCP readiness polling) to address silent failures of scheduled tasks with non-ASCII paths, and provides a one-click restart entry.
Core Features¶
- Settings Page Entry: Adds a “Restart Web Service” button in the General section of the DSH settings page.
- Automatic Restart and Refresh: After clicking, restart
dsh web, and the page automatically reloads after the service is ready. - Cross-Platform Compatibility: Compatible with Windows (terminal/desktop/service/scheduled tasks), Linux/macOS/WSL, running from the source tree, and global installation via nvm/volta/pnpm.
- Non-ASCII Path Fix: Uses a UTF-8 JSON configuration file instead of the command line to avoid silent failures with Chinese paths in scheduled tasks.
- Port Conflict Handling: If the port is occupied, it falls back to stopping the process that initiated the restart (
selfPid). - Readiness Verification: Verifies via
GET /dsh-restart-btn/ping, waits up to 45 seconds, and checks whetherhelper.launchappears. - UI Language: Bilingual Chinese and English interface, following the DSH language setting.
Installation¶
Use the following command to install the plugin:
dsh plugin --profile web add github:SiriusWJ/dsh-restart-btn
Typical Usage¶
- UI Operation: Click the “Restart Web Service” button in the General section of the DSH settings page.
- API Restart: Send
POST /dsh-restart-btn/restartwith the Body{"port":"3080"}. - Status Detection: Send
GET /dsh-restart-btn/ping; the response{ok, instance, pid, platform}indicates whether the new process is ready. - Workflow: After modifying a bundle, restart dsh once for the changes to take effect (restart manually the first time).
Notes¶
- Tab Behavior: During restart,
--no-openis not added, so an additional authorized tab is opened (consistent with the desktop shortcut); the old tab automatically reloads via Cookie. - Process Management: Only the process listening on that port is stopped. If dsh is managed by a supervisor, it may be started automatically, causing the port not to be released.
- System Dependencies: macOS requires
lsof; minimal Linux images will report errors iflsof/fuser/ssare absent. - Session Issues: After a restart, the session sometimes requires re-authorization (Cookie lifetime issue); the page will prompt the user to use the desktop shortcut.
- Identity Recognition: The frontend only refreshes the page when it successfully pings a different instance.
Logs and Troubleshooting¶
During runtime, the plugin outputs logs to a staging directory. If the path contains non-ASCII characters, it falls back sequentially.
- Windows:
%LOCALAPPDATA%\dsh-restart-btn - Linux/macOS:
$TMPDIR/dsh-restart-btn
The main log files include:
| File | Description |
|---|---|
restart.log |
Full restart process (stopping the process, releasing the port, starting, readiness, failure reason, and the tail of stderr). |
helper.launch |
Helper startup credential (PID), used to verify whether the helper was started successfully. |
dsh.out.log |
Standard output of the new service (including the token address). |
dsh.err.log |
Standard error output of the new service. |
Ecosystem Background¶
The DeepSeek Harness philosophy is “everything is a plugin.” This plugin aims to standardize restart operations during the development workflow. The source code and documentation are available on GitHub.