[
https://issues.apache.org/jira/browse/KARAF-327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12977178#action_12977178
]
Bengt Rodehav commented on KARAF-327:
-------------------------------------
I browsed through the source code and ended up in the class
org.apache.karaf.shell.wrapper.Main. Seems like that's where all the action
takes place ...
If I correctly understand the code then the process is given 1,5 seconds to
finish up before it is killed. Since the default Camel behaviour is to keep the
process alive up to 300 s if there are any inflight exchanges that explains my
problems. I guess I will have to do any of the following:
a) Make sure that Camel's inflight timeout is less than Karaf's timeout. Would
it be possible to make Karaf's exit timeout (currently hardcoded to 1 s)
configurable?
b) Somehow configure Camel to shut down the routes as fast as possible if the
service is about to stop.
What I don't quite understand is why there is a difference in behaviour when
running Karaf as a service compared to running Karaf from the command line.
Intuitively I think that the behaviour should be the same. In the command line
case, Karaf waits for Camel to finish (even up to 300 s) while in the service
case there seems to be no connection between Camel's timeout (300 s) and
Karaf's stop behaviour. Karaf terminates after 1,5 seconds regardless of what
Camel does.
Do you have any ideas of how this should be configured? Ideally I would like
Karaf to wait for Camel no matter how Karaf was started.
> Graceful shutdown of Windows service, revisited
> -----------------------------------------------
>
> Key: KARAF-327
> URL: https://issues.apache.org/jira/browse/KARAF-327
> Project: Karaf
> Issue Type: Bug
> Components: wrapper
> Affects Versions: 2.1.2
> Environment: Windows XP SP 3
> Reporter: Bengt Rodehav
> Assignee: Achim Nierbeck
> Fix For: 2.1.3, 2.2.0
>
>
> I'm trying to make my Karaf service more resilient to shutdown. In particular
> I want my Camel routes to shutdown gracefully. I started this discussion a
> few months ago, see
> http://www.mail-archive.com/[email protected]/msg00084.html.
> Guillaume created the JIRA ticket KARAF-176 which is also resolved. I haven't
> had time to test this until now.
> It seems to me that the problem persists. I'm now using Karaf 2.1.2 and Camel
> 2.5.0. When I run Karaf from the command line and terminates Karaf by
> pressing <ctrl-D>, Camel will gracefully shutdown. It looks something like
> this:
> 2010-12-09 13:04:51,737 | INFO | FelixStartLevel | DefaultShutdownStrategy
> | mel.impl.DefaultShutdownStrategy 114 | Starting to graceful
> shutdown 1 routes (timeout 300 seconds)
> 2010-12-09 13:04:51,737 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 383 | Route: route1 suspended and
> shutdown deferred, was consuming from:
> Endpoint[file://C:\dev\Karaf\connect\common/data/interfaces/sample/file2file?delay=10000&include=%28%3Fi%29.*%28%3F%3C%21%5C.TMP%29&move=archive%2F%24%7Bdate%3Anow%3AyyyyMMdd%7D%2F%24%7Bfile%3Aonlyname%7D&moveFailed=failed%2F%24%7Bfile%3Aonlyname.noext%7D-%24%7Bdate%3Anow%3AyyyyMMddHHmmssSSS%7D.%24%7Bfile%3Aext%7D]
> 2010-12-09 13:04:51,737 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 422 | Waiting as there are still
> 1 inflight and pending exchanges to complete, timeout in 300 seconds.
> 2010-12-09 13:04:52,737 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 422 | Waiting as there are still
> 1 inflight and pending exchanges to complete, timeout in 299 seconds.
> 2010-12-09 13:04:53,737 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 422 | Waiting as there are still
> 1 inflight and pending exchanges to complete, timeout in 298 seconds.
> ...
> 2010-12-09 13:06:54,782 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 422 | Waiting as there are still
> 1 inflight and pending exchanges to complete, timeout in 177 seconds.
> 2010-12-09 13:06:55,782 | INFO | 1 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 442 | Route: route1 shutdown
> complete.
> 2010-12-09 13:06:55,782 | INFO | FelixStartLevel | DefaultShutdownStrategy
> | mel.impl.DefaultShutdownStrategy 146 | Graceful shutdown of 1
> routes completed in 124 seconds
> 2010-12-09 13:06:55,798 | INFO | FelixStartLevel |
> DefaultInflightRepository | l.impl.DefaultInflightRepository 93 |
> Shutting down with no inflight exchanges.
> 2010-12-09 13:06:55,798 | INFO | FelixStartLevel | DefaultCamelContext
> | e.camel.impl.DefaultCamelContext 1374 | Uptime: 2 minutes
> 2010-12-09 13:06:55,798 | INFO | FelixStartLevel | DefaultCamelContext
> | e.camel.impl.DefaultCamelContext 1375 | Apache Camel 2.5.0
> (CamelContext: Sample file transfer from file to file) is shutdown in 2
> minutes
> ...
> But when Karaf is running as a service (I run on Windows XP SP 3) and stop
> the service from the control panel. Karaf, and therefore Camel, is abruptly
> killed. It looks like this:
> 2010-12-09 12:36:11,103 | INFO | FelixStartLevel | DefaultShutdownStrategy
> | mel.impl.DefaultShutdownStrategy 114 | Starting to graceful
> shutdown 1 routes (timeout 300 seconds)
> 2010-12-09 12:36:11,103 | INFO | 4 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 383 | Route: route2 suspended and
> shutdown deferred, was consuming from:
> Endpoint[file://C:\dev\Karaf\connect\common/data/interfaces/sample/file2file?delay=10000&include=%28%3Fi%29.*%28%3F%3C%21%5C.TMP%29&move=archive%2F%24%7Bdate%3Anow%3AyyyyMMdd%7D%2F%24%7Bfile%3Aonlyname%7D&moveFailed=failed%2F%24%7Bfile%3Aonlyname.noext%7D-%24%7Bdate%3Anow%3AyyyyMMddHHmmssSSS%7D.%24%7Bfile%3Aext%7D]
> 2010-12-09 12:36:11,103 | INFO | 4 - ShutdownTask | DefaultShutdownStrategy
> | ultShutdownStrategy$ShutdownTask 422 | Waiting as there are still
> 1 inflight and pending exchanges to complete, timeout in 300 seconds.
> Nothing more is logged since the process is killed. I know that there is
> never a guarantee that Karaf will shutdown gracefully since the process might
> just die (e g out of power). But it would be nice if the control panel could
> be used for stopping the service since thats what most operations engineers
> do. There is always the option to log in to Karaf via SSH and issue the
> shutdown command before stopping the service but then it becomes too
> complicated for most people.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.