Allow configuring the daemon inactivity timeout#1240
Conversation
fujitatomoya
left a comment
There was a problem hiding this comment.
just a minor comment. i think this optional argument is nice to have, i also think that use case is well explained.
There was a problem hiding this comment.
Pull request overview
This PR makes the ROS 2 CLI daemon’s inactivity shutdown behavior configurable, allowing long-lived daemons (including “never time out”) to avoid periodic respawns and DDS rediscovery spikes.
Changes:
- Exposes an inactivity
--timeoutoption onros2 daemon start(default remains 2 hours; negative disables the timeout). - Plumbs the configured inactivity timeout through
spawn_daemon()into the daemon server loop. - Adds tests validating the CLI argument exposure and the timeout/never-timeout behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ros2cli/test/test_daemon_timeout.py | Adds new tests covering explicit daemon start inactivity timeout behavior. |
| ros2cli/ros2cli/verb/daemon/start.py | Adds ros2 daemon start --timeout and forwards it to spawn_daemon(). |
| ros2cli/ros2cli/node/daemon.py | Extends spawn_daemon() with inactivity_timeout and passes it into the daemon server. |
| ros2cli/ros2cli/daemon/init.py | Implements “negative timeout disables inactivity timeout” behavior and updates _ros2_daemon --timeout help text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The daemon shuts itself down after a fixed 2 hours of inactivity, after which the next ros2 command has to respawn it. Expose this as a --timeout option on `ros2 daemon start` (the default stays 2 hours), and let a negative value disable the timeout so the daemon keeps running until it is explicitly stopped. The value is threaded through spawn_daemon() via a new inactivity_timeout argument; the auto-spawn path keeps the 2 hour default. This also fixes _ros2_daemon's existing --timeout, where a negative value used to make the daemon exit immediately instead of disabling the timeout. Signed-off-by: Abderahmane BENALI <46283596+benaliabderrahmane@users.noreply.github.com>
d4aa609 to
206b0a4
Compare
|
Thanks for the review! Pushed an update addressing everything:
Kept it as a single commit since it's one logical change, happy to split it if you'd rather. |
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm with green CI.
|
Pulls: #1240 |
Fixes #1239.
The daemon's inactivity timeout was hard-coded to 2 hours. We run robots for days with a large number of nodes, and once the daemon has timed out an occasional ros2 CLI call respawns a node and triggers DDS discovery, which shows up as a CPU spike. This makes the timeout configurable so a single long-lived daemon can be kept around instead.
ros2 daemon start --timeout Nshuts the daemon down after N seconds of inactivity. The default is still 2 hours, so behavior is unchanged unless you ask for it.helpers.wait_for).spawn_daemon()gains aninactivity_timeoutargument; the auto-spawn path keeps the 2 hour default._ros2_daemon's existing--timeout: a negative value used to make the daemon exit immediately, now it disables the timeout.This intentionally only affects daemons started explicitly; auto-spawned daemons keep the 2 hour default.
Added
test/test_daemon_timeout.pycovering the new argument and the short-timeout / never-timeout behavior.