Hi folks,

I started to work on https://issues.apache.org/jira/browse/KARAF-7174
(finally :)).

Basically, the issue here is the following:
- log:tail command registers a custom PaxAppender to display log
events in the terminal (via the printEvent() method)
- we have a pipe thread created by log:tail command

On a local terminal, all is OK: when the user stops log:tail (using
CTRL-C), the thread is stopped, all good.
However, when log:tail is executed from a remote terminal (ssh), then
we have a problem when the ssh client timeout for instance: the
log:tail thread is still running on the Karaf side, resulting in an
accumulation of threads.

To prevent this, and address similar issues in the future, I started
to prototype a ChannelResourceCleaner whiteboard.
Basically, a shell command (and generally speaking any class) can
implement ChannelResourceCleaner interface and register this kind of
OSGi service.
The ChannelResourceCleaner interface defines the close() method.
In the Karaf ssh server, we add a session listener that reacts when a
disconnect event happens. When a disconnect happens, the Karaf ssh
server is looking for all ChannelResourceCleaner services and call
close() on each of them.

I created a draft PR (still WIP) illustrating this mechanism:
https://github.com/apache/karaf/pull/1884

What do you think about this approach ?

Thanks !
Regards
JB

Reply via email to