0

I am running my Rest based Java service on Jetty server using jetty-maven-plugin version 9.3.12.v20160915.

I want to be able to perform a graceful shutdown of my service, i.e. all running threads in the Java service must be thrown with Java InterruptedException. I have already written my code assuming the above in mind.

When I try using mvn jetty:stop, it stops my service but does not do a graceful shutdown. All threads are immediately killed (without doing the clean up I wanted it do in finally block of my code that would have got executed in case InterruptedException would have been thrown by jetty:stop command).

Is there a way to achieve graceful shutdown with jetty mvn plugin ?

Vijay Kansal
  • 809
  • 12
  • 26

1 Answers1

0

Graceful shutdown is a feature of jetty-distribution's start.jar (which initiates it and monitors it) and the Server lifecycle (which does the task).

Graceful shutdown is a production level feature.

You should not be running production instances of Jetty using jetty-maven-plugin.

The jetty-maven-plugin is for development time only, and any other use is a security hazard.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • I tried looking at it but still could not find the mechanism to achieve graceful application shutdown using jetty-distribution's start.jar. Can you please help with that ? Please note that I want to code to get InterruptedException(or any other such) thrown into my code in case graceful shutdown is requested. – Vijay Kansal Apr 21 '17 at 03:48