From cf3d9dcbd52e2f90bb01b9fb5d52523029b2794d Mon Sep 17 00:00:00 2001 From: sasaki takeru Date: Wed, 18 Mar 2026 08:23:51 +0900 Subject: [PATCH] fix: reduce docker stop timeout for faster restarts Pass -t 1 to docker stop, reducing SIGTERM-to-SIGKILL grace period from 10s to 1s. NanoClaw containers are stateless (--rm, mounted filesystems) so they don't need a long grace period. Makes restarts ~10x faster. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/container-runtime.test.ts | 6 +++--- src/container-runtime.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/container-runtime.test.ts b/src/container-runtime.test.ts index 08ffd59..d111bf6 100644 --- a/src/container-runtime.test.ts +++ b/src/container-runtime.test.ts @@ -41,7 +41,7 @@ describe('readonlyMountArgs', () => { describe('stopContainer', () => { it('returns stop command using CONTAINER_RUNTIME_BIN', () => { expect(stopContainer('nanoclaw-test-123')).toBe( - `${CONTAINER_RUNTIME_BIN} stop nanoclaw-test-123`, + `${CONTAINER_RUNTIME_BIN} stop -t 1 nanoclaw-test-123`, ); }); }); @@ -93,12 +93,12 @@ describe('cleanupOrphans', () => { expect(mockExecSync).toHaveBeenCalledTimes(3); expect(mockExecSync).toHaveBeenNthCalledWith( 2, - `${CONTAINER_RUNTIME_BIN} stop nanoclaw-group1-111`, + `${CONTAINER_RUNTIME_BIN} stop -t 1 nanoclaw-group1-111`, { stdio: 'pipe' }, ); expect(mockExecSync).toHaveBeenNthCalledWith( 3, - `${CONTAINER_RUNTIME_BIN} stop nanoclaw-group2-222`, + `${CONTAINER_RUNTIME_BIN} stop -t 1 nanoclaw-group2-222`, { stdio: 'pipe' }, ); expect(logger.info).toHaveBeenCalledWith( diff --git a/src/container-runtime.ts b/src/container-runtime.ts index c4acdba..5a4f91e 100644 --- a/src/container-runtime.ts +++ b/src/container-runtime.ts @@ -59,7 +59,7 @@ export function readonlyMountArgs( /** Returns the shell command to stop a container by name. */ export function stopContainer(name: string): string { - return `${CONTAINER_RUNTIME_BIN} stop ${name}`; + return `${CONTAINER_RUNTIME_BIN} stop -t 1 ${name}`; } /** Ensure the container runtime is running, starting it if needed. */