-
Notifications
You must be signed in to change notification settings - Fork 1
Fix ROS packages service shutdown with proper signal handling and timeouts #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
Co-authored-by: Charbel Toumieh <[email protected]>
Co-authored-by: nielmistry <[email protected]>
Co-authored-by: nielmistry <[email protected]>
Co-authored-by: nielmistry <[email protected]>
…b8-6658fe26c54c Fix ROS nodes not shutting down cleanly with systemctl stop
…ration Co-authored-by: nielmistry <[email protected]>
…4e3-6701955ad2ab Replace ineffective WiFi power saving systemd service with NetworkManager configuration
Co-authored-by: nielmistry <[email protected]>
…d06-d8ad1cec6d7d Add --now flag and implement dynamic sleep timing for ros_packages_start.sh
|
@copilot also add a ros_kill alias in the ~/.bashrc |
Co-authored-by: nielmistry <[email protected]>
Co-authored-by: nielmistry <[email protected]>
Added the |
|
@copilot this approach doesn't really work. there should be a clean way to stop this without relying on the timeout and the pkill. and the way that you've done it doesn't work anyways. |
…launch processes Co-authored-by: nielmistry <[email protected]>
You're absolutely right. I've replaced the pkill workaround with proper ROS shutdown handling. The solution now uses sigterm_timeout and sigkill_timeout parameters on ExecuteProcess actions in the launch file, allowing ROS launch to cleanly shut down all child processes. The systemd service now uses proper signal handling with a reasonable 45-second timeout instead of force-killing processes. (commit 7c44e4b) |
Problem
When calling
systemctl --user stop ros_packageson drones, the service takes an extremely long time to stop and often hangs indefinitely. The ROS2 processes, particularly those launched viaros2 launch, don't respond properly to shutdown signals.Root Cause
The issue was caused by improper shutdown handling in the ROS launch configuration:
Solution
Implemented proper signal handling and timeout configuration throughout the ROS launch stack:
Added process-specific timeout handling:
Enhanced systemd service timeout:
Simplified manual cleanup:
Shutdown Sequence
The new shutdown process follows this clean sequence:
systemctl stopsends SIGTERM to the main ros2 launch processKey Improvements
Testing
The fix ensures:
This provides a robust, clean shutdown mechanism that respects ROS2's process lifecycle while preventing indefinite hangs.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.