dsh-services-manager: Unified Management of Local Background Services in DSH

Introduction

When developing Agents on DSH Desktop or Web, it is common to run local network services such as mechanics web, self-hosted APIs, static preview sites, etc., simultaneously. These processes are scattered across terminals. Checking if a port is listening, whether it was started by oneself, or where the logs are after exiting often requires manual checking of netstat or switching windows. The DSH community plugin dsh-services-manager (maintainer chanyuenpang) adds a “Service Management” partition in Settings, using a JSON configuration to register services, and completing view status, start/stop, and view logs in the panel; it also allows registration and start/stop via Agent native interfaces or the standalone CLI dsh-services. Categorized under admin-security, it emphasizes process identity verification rather than general orchestration. This article introduces its positioning, capabilities, and installation usage; facts are based on the GitHub README.

Overview

dsh-services-manager targets DSH 0.2 Desktop / Web and manages background network services on the current host machine (including DSH itself, mechanics web, tiny-world Web prototypes, and user-registered items). It is not a cross-machine container platform, nor does it perform general process orchestration.

The core concept is Configuration-Driven: Service definitions are centralized in <DSH_HOME>/.dsh-services-manager/services.json (default DSH_HOME is ~/.dsh), and panel edits write back to this file; runtime states (PID, exit codes, etc.) are not written to the file. It performs explicit identity matching for port occupiers (takeover / match) to distinguish between “started by this plugin” and “externally existing” processes.

Core Features

Settings Page: Service Management

After opening Settings → Service Management (the navigation uses a generic gear icon; the DSH settings shell does not support custom icons for third-party partitions), you can:

  1. View Status: Whether the port is listening, the occupying PID, source (this plugin / external), recent exit code or error, and optional HTTP health probes (probe).
  2. One-click Operations: Start, Stop, Restart, Refresh, View Logs.
  3. Persistent Start/Stop: Manual start saves autostart=true first, manual stop saves false; restart keeps the original strategy; plugin loading only restores items with autostart=true.
  4. Restart Current DSH: Executes approximately 3 seconds after single confirmation in the panel; Desktop only restarts the current Electron application tree and reopens it, while Web preserves the host’s original restart semantics.

When the partition is open, it polls and refreshes every 4 seconds and pauses when the page is not visible. The summary row shows Total / Running / Stopped / Abnormal and data freshness; daily additions, deletions, and modifications can be done via the form without manually writing JSON. “Advanced: Directly Edit JSON” is used to bulk modify fields not covered by the form, such as env and probe.

Right-side Web Service Launcher (0.2.6)

The right sidebar + → Web Services lists registered services that are running and have an HTTP(S) address (DSH itself is not listed). Each row contains only the name and two icons: open in DSH’s built-in browser or open in the system’s default browser; management is still completed in the Settings page. Stopped services are automatically hidden; they are not started or stopped by opening a web page, nor is autostart modified via this method.

Agent and Bundled Skills (0.2.4 / 0.2.5)

When calling /services-manager inside Desktop DSH, the Agent can discover artifacts, register, ensure they are running, and deliver URLs, without requiring a token or manual user intervention. The package includes skills/services-manager/; after enabling the plugin, dsh-services-manager-skills registers a skill with the same name to DSH’s native skills registry, allowing the Agent to directly load services-manager. Permissions are categorized into read-only, workspace-write (changes require host approval), danger-full-access, etc. For specific contracts, see skills/services-manager/SKILL.md in the repository.

Standalone CLI: dsh-services

The package provides dsh-services and does not require cloning the development repository. After installing with a profile, the PATH may not necessarily include the bin directory; you can use:

& "<profile>/node_modules/.bin/dsh-services.cmd" --help
node "<profile>/node_modules/dsh-services-manager/src/cli.mjs" --help

When connecting to an external DSH, you need to set DSH_SERVICES_URL=http://127.0.0.1:<port>. The token is obtained by the user from the authorized access URL and placed in DSH_SERVICES_TOKEN or --token-stdin; it only supports loopback (127.0.0.1). Common usage includes: register --file service.json, list, get, start ID, stop ID. Configuration writing includes expectedRevision; in case of conflict, use get to verify and resubmit with --revision.

Installation and Enablement

Compatible Baseline: DSH Desktop/Web 0.2.2-rc.1 and above (current package version in package.json is 0.2.6, engines.dsh is >=0.2.2-rc.1), Cordis >= 4.1, Node >= 20. License MIT.

Desktop

Select “Install” in the Plugin Manager and enter the npm package name or fixed version:

dsh-services-manager

or:

dsh-services-manager@0.2.6

Web profile

dsh plugin --profile web add dsh-services-manager

You can also use GitHub Release pre-built packages:

https://github.com/chanyuenpang/dsh-services-manager/releases/download/v0.2.6/dsh-services-manager-0.2.6.tgz
dsh plugin --profile web add https://github.com/chanyuenpang/dsh-services-manager/releases/download/v0.2.6/dsh-services-manager-0.2.6.tgz

Community directories such as dsh-market allow searching for dsh-services-manager; the DSH ecosystem follows the philosophy of “everything is a plugin,” and the directory site has no official affiliation with DeepSeek or Huafan. Whether a restart is required depends on the installation result in the Plugin Manager; installation does not authorize automatic restart. The first installation will not import the author’s service list; paths and commands must be registered manually. Before installing into a formal profile, the official recommendation is to complete a real startup test in an isolated sandbox (see AGENTS.md in the repository).

The plugin declares dependencies subprocess, connection, and webServer by itself; the package patches connection to add webServer, and generally no manual modification of the profile is required by the user.

Typical Usage

Configuration File

The first run only writes an empty list if the file does not exist; upgrades will not overwrite existing services.json. Example (paths and commands must be replaced with actual values on the machine):

{
  "version": 1,
  "services": [
    {
      "id": "mechanics-web",
      "title": "Mechanics Web",
      "port": 4319,
      "host": "127.0.0.1",
      "url": "http://127.0.0.1:4319/",
      "command": "node \"C:\\...\\cli.mjs\" web --port 4319",
      "cwd": "C:/Services/My API",
      "autostart": false,
      "autoStopOnExit": true,
      "takeover": "match",
      "match": { "commandLinePattern": "@veewo[\\\\/]mechanics..." },
      "probe": { "path": "/health", "expectStatus": 200 },
      "env": { "NODE_ENV": "development" }
    }
  ]
}

Semantic points: id must be stable and unique (dsh is a reserved value); when port is present, activity is determined by the port being LISTENING; takeover: match requires the command line of the occupying port process to match match.commandLinePattern (the old force no longer bypasses validation). Saving failures will reject the write; external modification of the file will result in CONFIG_CONFLICT, and the panel will prompt to reload. Startup commands do not support pipes, redirects, or && (explicitly rejected on Windows).

CLI Registration

dsh-services register --file service.json
dsh-services list
dsh-services start mechanics-web

register with an existing id only merges explicit fields; when the conflict exit code is 5, you should first use get and then resubmit with --revision.

Use Cases and Notes

Who is this for: Developers who use DSH locally for development and need to align multiple local Web/APIs with Agent workflows; people who want to uniformly start/stop, view logs, and perform health checks via a panel, or let Agents automatically register Web artifacts through the services-manager skill.

Must Note:

  1. The plugin starts commands on the host with the current DSH process permissions; only register trusted commands. “Restart DSH” requires separate confirmation.
  2. Before installation, you should review the source code and license.
  3. The CLI token represents existing host access permissions, not the Agent permission sandbox; do not write the token into command arguments, chats, or logs.
  4. Configuration success and process success are not atomic transactions; on failure, you should first check get/status and review fields such as policyCommitted and configRevision to avoid blind rollback.

Conclusion

dsh-services-manager gathers “local background services” into a partition in DSH Settings: JSON is the sole configuration source, and the panel and CLI have clear division of labor, with identity verification for port occupation. When you need to check item information or submit an issue, you can use the community directory page and GitHub repository:

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

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

Xiaoye