Hi!

I want to be able to shutdown Dropwizard from an end point. My current
solution looks like this:

package com.example;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("desist")
@Produces(MediaType.APPLICATION_JSON)
public class DesistResource {
    private final static Logger logger =
LoggerFactory.getLogger(DesistResource.class);
    private final static String BYE = "So long and thanks for all the fish.";

    @GET
    public String desist() {
        desistShortly();
        return "{\"message\": \"" + BYE + "\"}";
    }

    private void desistShortly() {
        Runnable sender = () -> {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            logger.info(BYE);
            System.exit(17);
        };

        new Thread(sender).start();
    }
}

It does the job, but it is a bit rough (to say the least...).

I would like to

* Jetty should stop to accept calls
* When all current calls have been processed, kill the application

My current concrete question is how do I get hold of Jetty and stop it
to accept calls?

And for bonus points, can I poll Jetty for the current number calls
being processed?

/Thomas

-- 
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://www.thinkcode.se/blog
Twitter: @thomassundberg

Better software through faster feedback

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to