How to gracefully terminate rosbridge server node?

asked 2019-09-19 07:05:31 -0500

AndreasVH gravatar image

rosbridge_server version: 0.11.3-1bionic.20190903.125723

I am running a rosbridge server node in my setup. I want to be able to shut down my ROS system. For other nodes just sending SIGINT (pressing Ctrl+C in the terminal after a roslaunch) seems to shut them down just fine. rosbridge_server does not seem to want to ever exit at any point after a client has been connected(before the first client connects it exits just fine. After I have this issue, even if the client disconnects again before I try to shut down). The following is the terminal output after ^C in the terminal:

^C[rosapi-2] killing on exit
[rosbridge_websocket-1] killing on exit
[rosbridge_websocket-1] escalating to SIGTERM
[rosbridge_websocket-1] escalating to SIGKILL
Shutdown errors:
* process[rosbridge_websocket-1, pid 23896]: required SIGKILL. May still be running.
shutting down processing monitor...
... shutting down processing monitor complete
done

This whole thing takes 10ish seconds, presumably the operating system waiting nicely for the process to end.

The open web sockets will not be gracefully disconnected if there are any. Potential clients are left hanging. (this is kind of ironic since the server does not seem to handle clients timing out very nicely itself. I am preparing a separate question about this)

What I would like to achieve is for rosbridge_server to close all open connections (and release other resources it might be holding that I don't know about) and then shutdown immediately after sending the SIGINT (or some other signal I can relatively easily generate). Is this possible? Does anyone have some hints/tips/tricks for fixing this if it requires modifying the rosbridge_server sources?

edit retag flag offensive close merge delete