/** Stops the local server thread if it is running. */ public void stopLocalServer() { if (checkLocalServer()) { // TODO: stopProcess (actually Process.destroy()) hangs on Macs... // doesn't seem to kill the children properly if (!McIDASV.isMac()) { thread.stopProcess(); } thread.interrupt(); thread = null; EventBus.publish(McservEvent.STOPPED); logger.debug("stopped mcservl? checkLocalServer={}", checkLocalServer()); } else { logger.debug("mcservl is not running."); } }
/** Starts the local server thread (if it isn't already running). */ public void startLocalServer() { if (new File(ADDE_MCSERVL).exists()) { // Create and start the thread if there isn't already one running if (!checkLocalServer()) { if (!testLocalServer()) { LogUtil.userErrorMessage("Local servers cannot write to userpath:\n" + USER_DIRECTORY); logger.info("Local servers cannot write to userpath"); return; } thread = new AddeThread(this); thread.start(); EventBus.publish(McservEvent.STARTED); logger.debug("started mcservl? checkLocalServer={}", checkLocalServer()); } else { logger.debug("mcservl is already running"); } } else { logger.debug("invalid path='{}'", ADDE_MCSERVL); } }
/** * Check to see if the thread is running. * * @return {@code true} if the local server thread is running; {@code false} otherwise. */ public boolean checkLocalServer() { return (thread != null) && thread.isAlive(); }