Stopping an Instance

This section describes how to shut down a Payara Micro Enterprise instance.

Stopping an Instance from the Command Line

Payara Micro instances can be stopped by either:

  • Using CTRL-C on the terminal in which Payara Micro Enterprise is running.

  • Sending a kill signal to the process ID of Payara Micro Enterprise

Stopping an Instance Programmatically

To shut down a Payara Micro instance programmatically, you will need to use the shutdown() method of the PayaraMicro or PayaraMicroRuntime class.

The shutdown() method of the PayaraMicro class must be called on the instance of Payara Micro that you want to shut down, so will realistically only be used on a PayaraMicro instance variable:

import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;

public class EmbeddedPayara{

    public static void main(String[] args) throws BootstrapException{

        PayaraMicro micro = PayaraMicro.getInstance();
        micro.bootStrap();
        micro.shutdown();
    }
}

The shutdown() method of the PayaraMicroRuntime class is tied to an instance variable, so is used in much the same way:

import fish.payara.micro.PayaraMicro;
import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicroRuntime;

public class EmbeddedPayara{
    public static void main(String[] args) throws BootstrapException{

        PayaraMicroRuntime instance = PayaraMicro.bootstrap();
        instance.shutdown();
    }
}