Source: Source pull request number: 227 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: feat(shutdown): graceful shutdown timeout with force exit | 优雅关闭超时
Author: mechanic-Q
State: open
Draft: no
Merged: no
Head: mechanic-Q/agentmemory:feature/graceful-shutdown-timeout @ b359e61
Base: main @ 1c8713f
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-05-02T07:26:39Z
Updated: 2026-05-17T09:42:42Z
Closed: (not closed)
Merged at: (not merged)
Original PR body:
Summary | 概述
Add a shutdown timeout that force-exits the process if graceful shutdown hangs, preventing zombie processes that require manual kill.
添加关闭超时机制,防止进程因 sdk 连接卡死而僵死。
Motivation | 动机
When the iii-engine WebSocket connection is stuck or the viewer server refuses to close, the shutdown handler hangs indefinitely. SIGTERM from systemd times out after 90s and sends SIGKILL, but during those 90s the process is unresponsive. Adding a configurable force-exit timeout ensures clean termination in bounded time.
当 iii-engine 连接卡死或 viewer 服务器拒绝关闭时,shutdown 流程永久挂起,形成僵尸进程。
Changes | 改动
- Added
AGENTMEMORY_SHUTDOWN_TIMEOUT_MS env var (default: 10000ms)
- On SIGINT/SIGTERM, starts a timer that calls
process.exit(0) if shutdown exceeds the timeout
- Timer uses
unref() so it doesn't prevent normal exit if shutdown completes quickly
- Calls
clearTimeout when shutdown completes normally
Backwards Compatibility | 向后兼容
Default timeout is 10s. Completely transparent when shutdown works normally — the timer is cleared before firing.
Summary by CodeRabbit
- Bug Fixes
- Improved shutdown robustness by implementing a configurable timeout mechanism (default 10 seconds) that ensures the application exits cleanly rather than hanging indefinitely during shutdown.
Local branch:
Fork PR:
Fork decision:
Verification:
Notes:
Source: Source pull request number: 227 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: feat(shutdown): graceful shutdown timeout with force exit | 优雅关闭超时
Author: mechanic-Q
State: open
Draft: no
Merged: no
Head: mechanic-Q/agentmemory:feature/graceful-shutdown-timeout @ b359e61
Base: main @ 1c8713f
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-05-02T07:26:39Z
Updated: 2026-05-17T09:42:42Z
Closed: (not closed)
Merged at: (not merged)
Original PR body:
Summary | 概述
Add a shutdown timeout that force-exits the process if graceful shutdown hangs, preventing zombie processes that require manual kill.
添加关闭超时机制,防止进程因 sdk 连接卡死而僵死。
Motivation | 动机
When the iii-engine WebSocket connection is stuck or the viewer server refuses to close, the shutdown handler hangs indefinitely. SIGTERM from systemd times out after 90s and sends SIGKILL, but during those 90s the process is unresponsive. Adding a configurable force-exit timeout ensures clean termination in bounded time.
当 iii-engine 连接卡死或 viewer 服务器拒绝关闭时,shutdown 流程永久挂起,形成僵尸进程。
Changes | 改动
AGENTMEMORY_SHUTDOWN_TIMEOUT_MSenv var (default: 10000ms)process.exit(0)if shutdown exceeds the timeoutunref()so it doesn't prevent normal exit if shutdown completes quicklyclearTimeoutwhen shutdown completes normallyBackwards Compatibility | 向后兼容
Default timeout is 10s. Completely transparent when shutdown works normally — the timer is cleared before firing.
Summary by CodeRabbit
Local branch:
Fork PR:
Fork decision:
Verification:
Notes: