Implementation:1mcp app Agent runServeRestart
| Knowledge Sources | |
|---|---|
| Domains | Process_Management, CLI |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete CLI command for cooperatively restarting a running 1MCP runtime by stopping the existing instance and starting a fresh background supervisor.
Description
The runServeRestart function implements `serve --restart`. It resolves the runtime scope, stops the existing runtime (via cooperative drain or legacy stop), and starts a fresh background runtime. The function composes `runStop` and `runBackground` with dependency injection for testability. It handles the case where no runtime is running by starting fresh, and supports preflight validation of the replacement configuration.
Usage
Import this function when you need to:
- Cooperatively restart a running 1MCP runtime
- Replace a running runtime with a fresh background instance
- Handle the case where no runtime is currently running
Code Reference
Source Location
- Repository: 1MCP Agent
- File: src/commands/serve/serveRestart.ts (L27-47), src/commands/serve/cooperativeRuntime.ts (L288)
Signature
export async function runServeRestart(
parsedArgv: ServeOptions,
deps?: RunRestartDeps,
): Promise<void>;
export async function restartCooperativeRuntime(
options: ServeOptions,
): Promise<void>;
Import
import { runServeRestart } from '@src/commands/serve/serveRestart.js';
import { restartCooperativeRuntime } from '@src/commands/serve/cooperativeRuntime.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| parsedArgv | ServeOptions | Yes | Full serve options |
Outputs
| Name | Type | Description |
|---|---|---|
| exit code | number | 0 on success, non-zero on failure |
Usage Examples
Restart Runtime
1mcp serve --restart
1mcp serve --restart --drain-timeout 30 --on-drain-timeout restart