This repository was archived by the owner on Apr 15, 2026. It is now read-only.
v0.2.0-beta3
·
20 commits
to main
since this release
feat: cleanup timeout for process termination (#207) Implement configurable cleanup timeout to control how long the system waits for process cleanup verification before triggering forced shutdown. This replaces the hardcoded 10-second timeout with a user-configurable value. Configuration: - Add --cleanup-timeout CLI flag (default: 10s, env: COG_CLEANUP_TIMEOUT) - Flow: CLI → Config → Runner for proper field injection Implementation changes: - Replace hardcoded timeout with context.WithTimeout() pattern - Improve check interval from 100ms to 10ms for more responsive detection - Add injectable verifyFn field to Runner for comprehensive testing - Update terminology from "ungraceful shutdown" to "forced shutdown" Testing improvements: - Migrate time-dependent tests to Go 1.25 synctest for deterministic execution - Add comprehensive test coverage for timeout scenarios and multiple ForceKill calls - Use safe high PID values (9999999) and proper mocking to prevent real process operations - Configure linter to handle synctest patterns correctly This enables users to customize cleanup wait times based on their specific workload requirements while maintaining safe defaults. * Address leaking coglets from test The test harness now properly cleans up orphaned coglet processes when interrupted: Key Features: - Cross-platform compatibility: Works on both macOS (Darwin) and Linux - Robust process discovery: Uses pgrep -f coglet as primary method, falls back to ps with platform-specific flags - Safe process killing: Validates we can signal processes before attempting to kill them - Process group cleanup: Kills both process groups and individual processes - Safety measures: Never kills ourselves, our parent, or PID 1 - Signal handling: Responds to both SIGINT (ctrl+c) and SIGTERM Implementation Details: - killAllChildProcesses() finds and kills coglet processes during cleanup - findCogletProcesses() tries pgrep first, falls back to ps - Platform-specific ps flags: -ax on macOS, -e on Linux - Process ownership validation through signal testing before killing - Integrated into existing TestMain signal handler --------- Co-Authored-By: Michael Dwan <m@dwan.io> Co-authored-by: Morgan Fainberg <code@tempusfrang.it>