MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / forceStopDaemon

Function forceStopDaemon

src/cli/daemon-control.ts:89–122  ·  view source on GitHub ↗
(socketPath: string)

Source from the content-addressed store, hash-verified

87 * Uses registry ownership metadata to stop the process before unregistering daemon files.
88 */
89export async function forceStopDaemon(socketPath: string): Promise<void> {
90 const entry = findDaemonRegistryEntryBySocketPath(socketPath);
91 if (!entry) {
92 throw new Error(
93 `Cannot force-stop daemon at ${socketPath}: daemon registry metadata is missing`,
94 );
95 }
96
97 const lock = acquireDaemonRegistryMutationLock(entry.workspaceKey);
98 if (!lock) {
99 throw new Error(`Unable to acquire daemon registry lock for ${entry.workspaceKey}`);
100 }
101
102 let termSent: boolean;
103 try {
104 validateCurrentRegistryEntry(entry, readDaemonRegistryEntry(entry.workspaceKey), socketPath);
105 termSent = signalDaemonPid(entry.pid, 'SIGTERM');
106 } finally {
107 lock.release();
108 }
109 if (termSent && !(await waitForPidExit(entry.pid, FORCE_STOP_SIGNAL_TIMEOUT_MS))) {
110 const killSent = signalDaemonPid(entry.pid, 'SIGKILL');
111 if (killSent && !(await waitForPidExit(entry.pid, FORCE_STOP_SIGNAL_TIMEOUT_MS))) {
112 throw new Error(`Daemon PID ${entry.pid} did not exit after SIGKILL`);
113 }
114 }
115
116 cleanupWorkspaceDaemonFiles(entry.workspaceKey, {
117 pid: entry.pid,
118 socketPath,
119 instanceId: entry.instanceId,
120 allowLiveOwner: true,
121 });
122}
123
124export interface StartDaemonBackgroundOptions {
125 socketPath: string;

Callers 4

invokeViaDaemonMethod · 0.90
ensureDaemonRunningFunction · 0.85

Calls 8

readDaemonRegistryEntryFunction · 0.90
signalDaemonPidFunction · 0.85
waitForPidExitFunction · 0.85
releaseMethod · 0.65

Tested by

no test coverage detected