- ✅ Added
last_startedfield to track when tasks were last started - ✅ Added
restart_countto track automatic restart attempts - ✅ Added
last_exit_codeto track exit status of completed tasks - ✅ Maintained backward compatibility with existing task configurations
- ✅ Enhanced
start_task()with better process validation:- Working directory existence check
- Process state validation (check if supposedly running processes are actually alive)
- Enhanced error handling with troubleshooting tips
- ✅ Improved
stop_task()with graceful shutdown:- SIGTERM before SIGKILL for graceful shutdown
- Process group signal handling for shell scripts
- Proper zombie process cleanup
- Exit code capture
- ✅ Added automatic log rotation when files exceed 10MB
- ✅ Enhanced
show_logs()with real-time following capability - ✅ Added
--followflag for tail-f style log monitoring - ✅ Improved log output formatting for both stdout and stderr
- ✅ Better error handling for missing or unreadable log files
- ✅ Implemented
follow_logs()function with:- File position tracking to show only new content
- Support for multiple log files (stdout/stderr)
- Proper file handling and error recovery
- 100ms polling interval for responsiveness
- ✅ Updated
print_task_details()to show:- Last start time
- Restart count
- Last exit code
- Enhanced formatting
- ✅ Added
is_process_running()helper function:- Unix signal-based process checking
- Cross-platform compatibility stubs
- ✅ Added process group signal handling:
send_signal_to_process_group()for proper shell script management- SIGTERM/SIGKILL sequence for graceful shutdown
- ✅ Implemented
check_and_restart_tasks()function:- Detects failed processes that should auto-restart
- Restart attempt limiting (max 5 attempts)
- Proper delay between restart attempts
- Restart count tracking
- ✅ Added
--followflag to logs command - ✅ Improved help text and parameter descriptions
- ✅ Better error messages with actionable troubleshooting tips
- ✅ Added libc dependency for Unix systems only
- ✅ Platform-specific code for signal handling
- ✅ Fallback implementations for non-Unix systems
- ✅ Better error handling throughout the codebase
- ✅ Reduced code duplication
- ✅ Enhanced logging and user feedback
- ✅ Proper resource cleanup and memory management
- ✅ Task creation with new fields
- ✅ Enhanced status display showing new information
- ✅ Log viewing with both stdout and stderr
- ✅ Log file rotation functionality
- ✅ Process state detection
- ✅ Graceful task stopping
- ✅ Backward compatibility with existing tasks
⚠️ Signal handling requires adjustment on some Unix systems⚠️ Auto-restart function implemented but not actively triggered (needs scheduling)⚠️ Real-time log following requires Ctrl+C to stop (by design)
- Log rotation prevents disk space issues
- Efficient file position tracking for log following
- Minimal resource usage for process monitoring
- Proper cleanup prevents resource leaks
- Better file permission validation
- Process group isolation for shell scripts
- Safer signal handling
- Enhanced binary validation and diagnostics
- Existing task configurations will be automatically upgraded
- New log paths will be created for older tasks on first start
- All existing functionality remains unchanged
- No breaking changes to the CLI interface
The hyperV service manager is now significantly more robust, feature-rich, and suitable for production use with proper process management, logging, and monitoring capabilities.