public void stop()

in appengine-plugins-core/src/main/java/com/google/cloud/tools/appengine/operations/DevServer.java [196:226]


  public void stop(StopConfiguration configuration) throws AppEngineException {
    Preconditions.checkNotNull(configuration);
    HttpURLConnection connection = null;
    String host = configuration.getHost() != null ? configuration.getHost() : DEFAULT_HOST;
    int port = configuration.getPort() != null ? configuration.getPort() : DEFAULT_PORT;
    URL adminServerUrl = null;
    try {
      adminServerUrl = new URL("http", host, port, "/_ah/admin/quit");
      connection = (HttpURLConnection) adminServerUrl.openConnection();
      connection.setDoOutput(true);
      connection.setDoInput(true);
      connection.setRequestMethod("POST");
      connection.getOutputStream().write('\n');
      connection.disconnect();
      int responseCode = connection.getResponseCode();
      if (responseCode < 200 || responseCode > 299) {
        throw new AppEngineException(
            adminServerUrl + " responded with " + connection.getResponseMessage() + ".");
      }
    } catch (IOException ex) {
      throw new AppEngineException("Error connecting to " + adminServerUrl, ex);
    } finally {
      if (connection != null) {
        try {
          connection.getInputStream().close();
        } catch (IOException ignore) {
          // ignored
        }
      }
    }
  }