{@inheritDoc}

@throws OperaRunnerException if launcher is shut down or not running
481365
public void startOpera() throws OperaRunnerException {
    assertLauncherAlive();

    try {
      byte[] request = LauncherStartRequest.newBuilder().build().toByteArray();

      ResponseEncapsulation res = protocol.sendRequest(MessageType.MSG_START, request);

      if (handleStatusMessage(res.getResponse()) != StatusType.RUNNING) {
        throw new IOException("launcher unable to start binary");
      }

      // Check Opera hasn't immediately exited (e.g. due to unknown arguments)
      sleep(OperaIntervals.PROCESS_START_SLEEP);

      res = protocol.sendRequest(MessageType.MSG_STATUS, request);

      if (handleStatusMessage(res.getResponse()) != StatusType.RUNNING) {
        throw new IOException(
            "Opera exited immediately; possibly incorrect arguments?  Command: " +
            binary.getCommands());
      }
    } catch (IOException e) {
      throw new OperaRunnerException("Could not start Opera: " + e.getMessage());
    }
  }
1077851
@Override
    public synchronized void stop(final StopContext context) {
        final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS;
        if (shutdownServers) {
            Runnable task = new Runnable() {
                @Override
                public void run() {
                    try {
                        serverInventory.shutdown(true, -1, true); // TODO graceful shutdown
                        serverInventory = null;
                        // client.getValue().setServerInventory(null);
                    } finally {
                        serverCallback.getValue().setCallbackHandler(null);
                        context.complete();
                    }
                }
            };
            try {
                executorService.getValue().execute(task);
            } catch (RejectedExecutionException e) {
                task.run();
            } finally {
                context.asynchronous();
            }
        } else {
            // We have to set the shutdown flag in any case
            serverInventory.shutdown(false, -1, true);
            serverInventory = null;
        }
    }
547364
@TaskAction
  public void runAction() throws AppEngineException, ProjectConfigurationException {
    devServers
        .newDevAppServer(CloudSdkOperations.getDefaultHandler(getLogger()))
        .run(runConfig.toRunConfiguration());
  }
439063
public function run()
    {

        try {
            // register shutdown handler
            register_shutdown_function($this->getDefaultShutdownMethod());

            // bootstrap the daemon
            $this->bootstrap();

            // mark the daemon as successfully shutdown
            $this->synchronized(function ($self) {
                $self->state = EnumState::get(EnumState::RUNNING);
            }, $this);

            // keep the daemon running
            while ($this->keepRunning()) {
                try {
                    $this->iterate($this->getDefaultTimeout());
                } catch (\Exception $e) {
                    $this->log(LogLevel::ERROR, $e->__toString());
                }
            }

            // clean up the instances and free memory
            $this->cleanUp();

            // mark the daemon as successfully shutdown
            $this->synchronized(function ($self) {
                $self->state = EnumState::get(EnumState::SHUTDOWN);
            }, $this);

        } catch (\Exception $e) {
            $this->log(LogLevel::ERROR, $e->__toString());
        }
    }
717779
private void stopAppLauncherAndServices() {
    try {
      this.applicationLauncher.stop();
    } catch (ApplicationException ae) {
      LOGGER.error("Error while stopping Gobblin Cluster application launcher", ae);
    }

    if (this.jobCatalog instanceof Service) {
      ((Service) this.jobCatalog).stopAsync().awaitTerminated();
    }
  }
1093624
@Override
    public synchronized void stop() {
        if (engine != null) {
            Future<Boolean> shutdown = engine.shutdown();
            final int SHUTDOWN_TIMEOUT = 30;
            try {
                LOGGER.debug("Shutting down engine to stop resource adapter");
                if ( ! shutdown.get(SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
                    // ModeShapeEngine somehow remained running, nothing to be done about it.
                    LOGGER.error(JcaI18n.unableToStopEngine);
                }
            } catch (TimeoutException e) {
                // Exception can be expected, but stack trace is logged to find where limit was defined
                LOGGER.error(e, JcaI18n.unableToStopEngineWithinTimeLimit, SHUTDOWN_TIMEOUT);
            } catch (InterruptedException e) {
                LOGGER.error(e, JcaI18n.interruptedWhileStoppingJcaAdapter,e.getMessage());
            } catch (ExecutionException e) {
                LOGGER.error(e, JcaI18n.errorWhileStoppingJcaAdapter,e.getMessage());
            }
            engine = null;
        }
    }
927956
public void shutdown() throws Exception {
        if (type == null) {
            return;
        }
        if (type instanceof Hub) {
            ((Hub) type).stop();
        }
        if (type instanceof SelfRegisteringRemote) {
            ((SelfRegisteringRemote) type).stopRemoteServer();
        }
        if (type instanceof SeleniumServer) {
            ((SeleniumServer) type).stop();
        }
        LOGGER.info("Selenium is shut down");
    }
983588
protected void execute(Runnable command) throws RejectedExecutionException
    {
        if (isDie())
        {
            logger.warn("AgiServer is shutting down: Refused to execute AgiScript");
            return;
        }

        getPool().execute(command);
    }
1373389
@Override
    public void shutdown() {
        try {
            verifyMaintainability();
        } catch (VerificationFailedException ex) {
            throw new RuntimeException("Can not shutdown " + this + "!", ex);
        }

        this.shutdownInitiated = true;
        try {
            dataObservable.shutdown();
        } finally {
            try {
                deactivate();
            } catch (CouldNotPerformException | InterruptedException ex) {
                ExceptionPrinter.printHistory("Could not shutdown " + this + "!", ex, logger);
            }
        }
    }
1058970
final void shutdown() {
        _enabled = false;
        _ignoredSegs.clear();
        
        if(_executor != null && !_executor.isShutdown()) {
            try {
                _executor.shutdown();
                _log.info("shutdown");
            } catch (Exception e) {
                _log.warn("shutdown abort", e);
            }
            
            try {
                _executor.awaitTermination(_shutdownTimeout, TimeUnit.SECONDS);
            } catch (Exception e) {
                _log.warn("shutdown abort", e);
            }
            
            if(_segTarget != null) {
                try {
                    _updateManager.endUpdate(_segTarget);
                } catch (Exception e) {
                    _log.warn("shutdown abort", e);
                }
            }
        }
        
        _executor = null;
        _state = State.DONE;
    }
166348
@Override
  protected void run() throws Exception {
    final ResourceLoader resourceLoader = new MojoResourceLoader(getRuntimeRealm(), getScriptpath());
    final Map<String, Object> context = createContext();
    final Map<String, Object> options = Maps.newHashMap();
    final ConsoleWindow console = getRuntime().createConsoleWindow();

    WindowHandle handle = console.open(getRuntimeRealm(), resourceLoader, context, options);
    handle.await();
  }
968090
@Override
    public void stopPlatform() {
        try {
            for (Entry<String, AgentController> e : this.createdAgents
                    .entrySet()) {
                AgentController ac = e.getValue();
                ac.kill();
            }
            for (Entry<String, ContainerController> e : this.platformContainers
                    .entrySet()) {
                ContainerController cc = e.getValue();
                cc.kill();
            }
            this.mainContainer.kill();
            this.runtime.shutDown();
        } catch (Exception e) {
            logger.warning("Warning shuting down JADE platform: "
                    + e.getMessage());
        }
    }
1010002
@Override
  public void run() {
    while (running) {
      try {
        handleIO();
      } catch (IOException e) {
        logRunException(e);
      } catch (CancelledKeyException e) {
        logRunException(e);
      } catch (ClosedSelectorException e) {
        logRunException(e);
      } catch (IllegalStateException e) {
        logRunException(e);
      } catch (ConcurrentModificationException e) {
        logRunException(e);
      }
    }
    getLogger().info("Shut down memcached client");
  }
1369481
@Override
	public synchronized boolean shutdown()
    {
    	if (!started)
    		return false;
    	
    	try
    	{
	        log.info("Server shutting down ...");
	        
	        // Undeploy bridges
	        undeployBridges();
	        
	        // Stop the tcp listener
	        if (tcpListener != null)
	        {
	        	tcpListener.stop();
	        	tcpListener = null;
	        }
	        
	        // Terminate the admin thread
	        if (adminThread != null)
	        {
	            adminThread.pleaseStop();
	            try
	            {
	                adminThread.join(ADMIN_THREAD_STOP_TIMEOUT*1000);
	                adminThread = null;
	            }
	            catch (InterruptedException e)
	            {
	                log.warn("Shutdown was interrupted while waiting for the admin thread to stop");
	            }
	        }
	        
	        // Undeploy engine
	        engine.undeploy();
	        try
	    	{
	    		if (jmxAgent != null)
	    			jmxAgent.unregister(new ObjectName(JMXAgent.JMX_DOMAIN+":type=Engines,engine="+engine.getName()));
	    	}
	    	catch (Exception e)
	    	{
	    		log.error("Cannot unregister local engine from JMX agent",e);
	    	}
	        
	        // Undeploy JMX
	        if (jmxAgent != null)
	        	jmxAgent.stop();
	        
	        started = false;
	        	        
	        log.info("Shutdown complete.");
	        
	        return true;
    	}
    	catch (Exception e)
    	{
    		log.error("Server shutdown failed",e);
    		return false;
    	}
    }
587744
@Override
    protected void doStop() throws Exception
    {
        log.info("stopping...");
        if (_client != null)
        {
            _client.shutdown();
            _client = null;
        }
        super.doStop();
        log.info("stopped.");
    }
76020
void markSuccess() {
    // It's possible that the dag is killed before this method is called.
    assertRunningOrKilling();
    changeStatus(Status.SUCCESS);
    for (final Node child : this.children) {
      child.runIfAllowed();
    }
    this.dag.updateDagStatus();
  }
526769
public static LauncherStatus runHelloReef(final Configuration runtimeConf, final int timeOut)
      throws BindException, InjectionException {
    final Configuration driverConf =
        Configurations.merge(HelloREEFHttp.getDriverConfiguration(), getHTTPConfiguration());
    return DriverLauncher.getLauncher(runtimeConf).run(driverConf, timeOut);
  }