MCPcopy
hub / github.com/codeaashu/claude-code / restart

Function restart

src/services/lsp/LSPServerInstance.ts:300–331  ·  view source on GitHub ↗

* Manually restarts the server by stopping and starting it. * * Increments restartCount and enforces maxRestarts limit. * Note: This is NOT automatic - must be called explicitly. * * @throws {Error} If stop or start fails, or if restartCount exceeds config.maxRestarts (default: 3)

()

Source from the content-addressed store, hash-verified

298 * @throws {Error} If stop or start fails, or if restartCount exceeds config.maxRestarts (default: 3)
299 */
300 async function restart(): Promise<void> {
301 try {
302 await stop()
303 } catch (error) {
304 const stopError = new Error(
305 `Failed to stop LSP server '${name}' during restart: ${errorMessage(error)}`,
306 )
307 logError(stopError)
308 throw stopError
309 }
310
311 restartCount++
312
313 const maxRestarts = config.maxRestarts ?? 3
314 if (restartCount > maxRestarts) {
315 const error = new Error(
316 `Max restart attempts (${maxRestarts}) exceeded for server '${name}'`,
317 )
318 logError(error)
319 throw error
320 }
321
322 try {
323 await start()
324 } catch (error) {
325 const startError = new Error(
326 `Failed to start LSP server '${name}' during restart (attempt ${restartCount}/${maxRestarts}): ${errorMessage(error)}`,
327 )
328 logError(startError)
329 throw startError
330 }
331 }
332
333 /**
334 * Checks if the server is healthy and ready to handle requests.

Callers

nothing calls this directly

Calls 4

stopFunction · 0.70
startFunction · 0.70
errorMessageFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected