Dropwizard: How to stop service programmatically

前端 未结 5 744
花落未央
花落未央 2021-01-04 06:13

To start the service, I know one uses new MyService().run(args). How to stop it?

I need to start and stop programmatically for setUp() and

5条回答
  •  隐瞒了意图╮
    2021-01-04 07:03

    Keep the environment variable around and add the following method to your application:

    public void stop() throws Exception {
      environment.getApplicationContext().getServer().stop();
    }
    

    Now you can call myService.stop() to stop the server.

提交回复
热议问题