protected String getWebServerName() { return options.getServletContainerLauncher().getName(); }
@Override protected int doStartUpServer() { // Create the war directory if it doesn't exist File warDir = options.getWarDir(); if (!warDir.exists() && !warDir.mkdirs()) { getTopLogger().log(TreeLogger.ERROR, "Unable to create war directory " + warDir); return -1; } Event jettyStartupEvent = SpeedTracerLogger.start(DevModeEventType.JETTY_STARTUP); boolean clearCallback = true; try { ui.setCallback(RestartServerEvent.getType(), this); ServletContainerLauncher scl = options.getServletContainerLauncher(); TreeLogger serverLogger = ui.getWebServerLogger(getWebServerName(), scl.getIconBytes()); String sclArgs = options.getServletContainerLauncherArgs(); if (sclArgs != null) { if (!scl.processArguments(serverLogger, sclArgs)) { return -1; } } isHttps = scl.isSecure(); // Tell the UI if the web server is secure if (isHttps) { ui.setWebServerSecure(serverLogger); } /* * TODO: This is a hack to pass the base log level to the SCL. We'll have * to figure out a better way to do this for SCLs in general. */ if (scl instanceof JettyLauncher) { JettyLauncher jetty = (JettyLauncher) scl; jetty.setBaseRequestLogLevel(getBaseLogLevelForUI()); } scl.setBindAddress(bindAddress); if (serverLogger.isLoggable(TreeLogger.TRACE)) { serverLogger.log(TreeLogger.TRACE, "Starting HTTP on port " + getPort(), null); } server = scl.start(serverLogger, getPort(), options.getWarDir()); assert (server != null); clearCallback = false; return server.getPort(); } catch (BindException e) { System.err.println( "Port " + bindAddress + ':' + getPort() + " is already is use; you probably still have another session active"); } catch (Exception e) { System.err.println("Unable to start embedded HTTP server"); e.printStackTrace(); } finally { jettyStartupEvent.end(); if (clearCallback) { // Clear the callback if we failed to start the server ui.setCallback(RestartServerEvent.getType(), null); } } return -1; }