mercredi 27 juillet 2016

How to terminate Google App Engine instance programmatically in Java?

I want to prevent Google App Engine instances from continuing to run when critical initialization fails. How can I do it programmatically in Java? System.exit() does not work in GAE.

I want to write it in the implementation of ServletContextListener like below.

public class AppContextListener implements ServletContextListener
{
    @Override
    public void contextInitialized(ServletContextEvent context)
    {
        try
        {
            // Initialization
        }
        catch (Throwable t)
        {
            // Fatal. Terminate this Google App Engine instance.
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent context)
    {
    }
}

Aucun commentaire:

Enregistrer un commentaire