dsh-restart-button: One-Click Restart for the DSH Desktop App

During the development or operation of the DSH desktop application, restarts are sometimes required to apply configuration changes, release ports, or recover from crashes. Manually closing the window and double-clicking the icon is not only inefficient but may also result in the loss of the current state. The dsh-restart-button implements one-click restart and automatic page recovery by adding a button to the bottom of the sidebar.

This is a client plugin maintained by FuriousKinght. It utilizes a Node.js helper process and the Windows taskkill command to forcefully restart the process tree in the packaged desktop application and automatically refresh the page.

Core Features

  • Sidebar Restart Entry: Adds a restart button to the bottom of the sidebar.
  • Automatic Page Refresh: After DSH restarts, the page automatically reloads and restores the connection.
  • Two-Step Confirmation: Clicking enters a 5-second confirmation state; a second click is required to execute the restart, preventing accidental triggers.
  • Forceful Process Termination: Uses taskkill /T /F to kill the entire process tree, ensuring old processes completely release ports and resources.
  • Platform Restriction: Only supports the Windows desktop version; terminal mode is not supported.

Technical Principles

The DSH desktop version is based on Electron. Electron’s app.relaunch() is only available in development mode, and the IPC channel from Host to Electron does not contain a “restart” message. Therefore, the plugin must restart the application from the outside.

To prevent child processes (Host) from becoming orphans and occupying ports after the main process is killed, the plugin uses WMI to create a Node.js helper process with WmiPrvSE.exe as the parent process. This helper process executes taskkill /T /F in the background to kill the entire process tree and then relaunches the executable. The page determines when to refresh by comparing process tokens.

Installation and Activation

Please ensure DSH 0.2.0-rc.2 or a newer version is installed before proceeding.

node tools/install.mjs --profile desktop     # Install
node tools/uninstall.mjs --profile desktop   # Uninstall

The code layer is hot-loaded via cordis.patch.yml, but running processes cache the old code, so a manual DSH restart is usually required once for the initial activation.

Verification

node verify/verify-install.mjs     # Browser-side validation
node verify/verify-relaunch.mjs    # Helper process survival validation

Notes

  • Version Requirement: DSH 0.2.0-rc.2 or a newer version is required. Older versions will refuse installation.
  • Not Configurable: The plugin does not provide a settings namespace.
  • Runtime Environment: Effective only in packaged desktop applications. If dsh web is run in the terminal, the plugin will attempt to kill the Shell, causing the terminal to close.

Summary

This plugin solves the cumbersome restart process of the DSH desktop application, ensuring restart reliability through low-level process management. For more details, please refer to the GitHub Repository or the Skill Tree Directory.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye