DSH Web is a long-running host process. Changes to plugins, configuration, or newly installed bundles do not take effect until a restart is performed. Manually restarting it usually requires several steps: opening a terminal, finding the PID, killing the process, starting the service, running a self-check, and refreshing the page. This process is tedious and lacks real-time feedback. This article introduces lnyuqian/dsh-restart-plugin, which uses a sidebar button or a conversation command to condense the process into a silent one-click operation.

Core Features

  • Dual-state sidebar button: Supports an expanded text display of [↻ Restart] and a collapsed icon display of ↻, with responsive animation and real-time synchronization of the sidebar state.
  • Countdown and status feedback: After clicking, a 10-second countdown begins, the page text turns light gray as a whole, and the button remains prominent, providing clear status feedback.
  • Silent execution: Uses wscript to start PowerShell silently, with no pop-up windows, no terminal window, and no new browser tab; the original page automatically refreshes to complete the process.
  • Self-check probe: After restart, automatically verifies both the port (3080) and the route (GET /_dsh/dsh-restart/state), and displays a prompt only when the self-check succeeds.
  • Conversation trigger: Supports using the dsh_restart tool in a conversation, suitable for scenarios where the current turn needs to be finalized.

Prerequisites

  • Operating system: Windows only (depends on schtasks / wscript / PowerShell; Linux / macOS are not supported).
  • DSH Web: It is recommended to use version 0.2.0-rc.x (version 0.1.0 can also run, but DSH 0.2.x may mark it as incompatible).
  • Node.js: Node.js >= 24.11 is required.
  • Permissions: The current user must have permission to create scheduled tasks.

Installation and Deployment

This plugin consists of two essential parts: the front-end plugin package and the local restart script chain. Neither can be omitted.

Step 1: Register the plugin package

Run the following command in the terminal to register the local directory as a dependency of the DSH Web profile:

dsh plugin --profile web add link:.\\dsh-restart-plugin

After registration, stop and restart dsh web, then hard-refresh the page in your browser (Ctrl+Shift+R). At this point, the restart button should appear in the sidebar, and the http://127.0.0.1:3080/_dsh/dsh-restart/state route should return the status normally.

Step 2: Deploy the restart script chain

The plugin package only contains front-end components; the restart logic (killing the process, starting the service, and self-checking) must be implemented through local scripts. Use the official installation script to deploy it with a single command:

powershell -ExecutionPolicy Bypass -File docs\\setup\\install.ps1 -InstallDir "$env:USERPROFILE\\.dsh-restart" -Seconds 10

This step automatically does three things:
1. Copies the template files to the specified directory and replaces placeholders based on the parameters.
2. Registers a scheduled task (default name: dsh-web-restart-20s).
3. Automatically updates the path constants in the plugin source code.

Note: .ps1 files must be saved as UTF-8 with BOM, and .vbs / .bat files must be saved as GBK, to ensure correct execution with Chinese paths.

Usage

  • Sidebar operation: Click the sidebar button, wait for the 10-second countdown to complete, and the page will automatically refresh and show “✅ Restart successful” in the top right corner.
  • Conversation operation: Type “restart” in the conversation to trigger the dsh_restart tool.
  • Scheduled task operation: Manually trigger the scheduled task from the command line:
    schtasks /Run /TN "dsh-web-restart-20s"

Working Principle

  1. Trigger: The user clicks the button or triggers the dsh_restart tool.
  2. Execution: The tool calls the dsh_restart route and triggers the scheduled task dsh-web-restart-20s.
  3. Waiting: wscript silently starts PowerShell, runs a 10-second countdown, and the entire page turns gray.
  4. Restart: After the countdown ends, the script kills the old host process and starts a new instance with the --no-open parameter.
  5. Self-check: After the new instance starts, the script verifies that port 3080 is listening and checks the self-check route.
  6. Wrap-up: If the self-check succeeds, the original page refreshes; if it fails, the button turns red to prompt you to retry.

Summary

By combining scheduled tasks with a script chain, this plugin addresses the problems of DSH Web restarts being tedious, error-prone, and lacking feedback. Before installing, ensure that your environment meets the prerequisites and that script files use the required encodings.

  • GitHub repository: https://github.com/lnyuqian/dsh-restart-plugin
  • Plugin directory: https://www.skillhub.cn/plugins/lnyuqian/dsh-restart-plugin