Tang-mm95/dsh-single-instance-guard
Aborts startup when another live dsh instance holds the same DSH_HOME data directory, preventing the concurrent session-log writes that corrupt transcripts.
Turns a silent session-log corruption into a loud startup failure. The JSONL session persistence backend documents one live writer per session but has no cross-process defense, so two dsh servers sharing one DSH_HOME — a desktop wrapper spawning its own server, or two dsh web processes — append batches with stale sequence cursors and corrupt session logs with errors like 'corrupt session log: seq gap in committed region'. The guard takes an exclusive lock on DSH_HOME at startup, checks whether the recorded holder is still alive, and aborts with a clear message instead of letting both processes write.
Install
# add to the profile's cordis.patch.yml BEFORE session-related bundles:
- insert:
- id: single-instance-guard
name: 'dsh-single-instance-guard'README's manual install block quoted verbatim, which it describes as working on any dsh install and which must be inserted before session-related bundles; the README notes the guard is a profile bundle whose manifest declares the same patch, so the CLI installs it as a patch layer. The README's npm line — dsh plugin --profile <profile> add dsh-single-instance-guard — is introduced with 'After publishing to npm' and leaves the profile field blank; registry check 2026-09-17 returned 404 for that name, so the manual row is the route that works today.
Compatibility
README: a zero-dependency plugin that takes an exclusive lock on the DSH_HOME data directory at startup. It creates <DSH_HOME>/.dsh-server.lock atomically with O_EXCL, holding pid, start time and hostname, and on conflict probes the holder's pid liveness so a live holder aborts startup loudly while a stale one does not. The README publishes a known-limits section alongside the diagnosis it responds to.
Details
- Repo: Tang-mm95/dsh-single-instance-guard
- Category: Development & Runtime
- Stars: 1
- Version: Profile patch row (no registry version asserted; repo 0★, MIT, last push 2026-08-16)
- Last push: 2026-08-16
- First seen: 2026-08-16
Recent updates
The README documents the failure it addresses, the lock protocol and the known limits rather than a release-by-release table.
FAQ
- How do I install it?
- The README's manual route works on any dsh install: add the insert row for id: single-instance-guard / name: 'dsh-single-instance-guard' to the profile's cordis.patch.yml, before session-related bundles. An npm form is mentioned as 'after publishing to npm' and that name returned 404 on 2026-09-17.
- What problem does it solve?
- Per the README, two dsh servers sharing one DSH_HOME append session batches with stale sequence cursors and corrupt the JSONL session logs; the guard turns that silent corruption into a loud startup failure.
- What if the previous process crashed?
- The README says the guard probes the holder's pid liveness, so a stale lock does not block startup while a live holder aborts it.