Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-327

Graceful shutdown of Windows service, revisited

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.2
    • 2.1.3, 2.2.0
    • karaf
    • None
    • Windows XP SP 3

    Description

      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/user@karaf.apache.org/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: Endpointfile://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: Endpointfile://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.

      Attachments

        1. camel-route.xml
          0.8 kB
          Achim Nierbeck

        Issue Links

          Activity

            People

              achim_nierbeck Achim Nierbeck
              rodehav Bengt Rodehav
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: