Stop a service on a remote host depending on the type of init system.
    Obviously, this should be done for RHEL/Fedora/CentOS systems.

    This function does not do any kind of detection.
332079
def stop_service(conn, service='ceph'):
    
    if is_systemd(conn):
        # Without the check, an error is raised trying to stop an
        # already stopped service
        if is_systemd_service_active(conn, service):
            remoto.process.run(
                conn,
                [
                    'systemctl',
                    'stop',
                    '{service}'.format(service=service),
                ]
            )
1076576
def rpc_stop(server_state):
    
    rpc_srv = server_state['rpc']

    if rpc_srv is not None:
        log.info("Shutting down RPC")
        rpc_srv.stop_server()
        rpc_srv.join()
        log.info("RPC joined")

    else:
        log.info("RPC already joined")

    server_state['rpc'] = None
141183
void stop( Instance instance, PluginInterface plugin ) throws IOException {

		String instancePath = InstanceHelpers.computeInstancePath( instance );
		if( instance.getStatus() != InstanceStatus.DEPLOYED_STARTED )
			this.logger.fine( instancePath + " cannot be stopped. Prerequisite status: DEPLOYED_STARTED (but was " + instance.getStatus() + ")." );
		else
			stopInstance( instance, plugin, false );
	}
1280380
def stop(self):
        

        self._hw_virtualization = False
        yield from self._stop_remote_console()
        yield from self._stop_ubridge()

        try:
            if (yield from self.is_running()):
                if self.acpi_shutdown:
                    # use ACPI to shutdown the VM
                    yield from self._control_vm("stop", "soft")
                else:
                    yield from self._control_vm("stop")
        finally:
            self._started = False
            self.status = "stopped"

            self._read_vmx_file()
            self._vmnets.clear()
            # remove the adapters managed by GNS3
            for adapter_number in range(0, self._adapters):
                vnet = "ethernet{}.vnet".format(adapter_number)
                if self._get_vmx_setting(vnet) or self._get_vmx_setting("ethernet{}.connectiontype".format(adapter_number)) is None:
                    if vnet in self._vmx_pairs:
                        vmnet = os.path.basename(self._vmx_pairs[vnet])
                        if not self.manager.is_managed_vmnet(vmnet):
                            continue
                    log.debug("removing adapter {}".format(adapter_number))
                    self._vmx_pairs[vnet] = "vmnet1"
                    self._vmx_pairs["ethernet{}.connectiontype".format(adapter_number)] = "custom"

            # re-enable any remaining network adapters
            for adapter_number in range(self._adapters, self._maximum_adapters):
                if self._get_vmx_setting("ethernet{}.present".format(adapter_number), "TRUE"):
                    log.debug("enabling remaining adapter {}".format(adapter_number))
                    self._vmx_pairs["ethernet{}.startconnected".format(adapter_number)] = "TRUE"
            self._write_vmx_file()

        yield from super().stop()
        log.info("VMware VM '{name}' [{id}] stopped".format(name=self.name, id=self.id))
197138
def halt_running():
    ''''''
    vultr = Vultr(API_KEY)

    try:
            serverList = vultr.server.list()
            #logging.info('Listing servers:\n%s', dumps(
            #serverList, indent=2
        #))
    except VultrError as ex:
        logging.error('VultrError: %s', ex)

    for serverID in serverList:
        if serverList[serverID]['power_status'] == 'running':
            logging.info(serverList[serverID]['label'] + " will be gracefully shutdown.")
            vultr.server.halt(serverID)
699664
def stop(self):
        
        if self.is_run:
            self._service.shutdown()
            self._service.server_close()
427587
public static void stop(Service service) {
    if (service != null) {
      Service.STATE state = service.getServiceState();
      if (state == Service.STATE.STARTED) {
        service.stop();
      }
    }
  }
131326
def signal_stop(self, mode):
        
        if self.is_single_user:
            logger.warning("Cannot stop server; single-user server is running (PID: {0})".format(self.pid))
            return False
        try:
            self.send_signal(STOP_SIGNALS[mode])
        except psutil.NoSuchProcess:
            return True
        except psutil.AccessDenied as e:
            logger.warning("Could not send stop signal to PostgreSQL (error: {0})".format(e))
            return False

        return None
792258
def stop(self, reason=''):
        
        key = '/status/sessions/terminate?sessionId=%s&reason=%s' % (self.session[0].id, quote_plus(reason))
        return self._server.query(key)
1295053
synchronized void stop(Integer timeout) {
        final InternalState required = this.requiredState;
        if(required != InternalState.STOPPED) {
            this.requiredState = InternalState.STOPPED;
            ROOT_LOGGER.stoppingServer(serverName);
            // Only send the stop operation if the server is started
            if (internalState == InternalState.SERVER_STARTED) {
                internalSetState(new ServerStopTask(timeout), internalState, InternalState.PROCESS_STOPPING);
            } else {
                transition(false);
            }
        }
    }
946278
def stop_accepting_passive_host_checks(self):
        
        if self.my_conf.accept_passive_host_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
            self.my_conf.accept_passive_host_checks = False
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
1248252
@Override
    public void stop()
    {
        // On linux, this doesn't entirely shut down Cassandra, just the RPC server.
        // jsvc takes care of taking the rest down
        logger.info("Cassandra shutting down...");
        if (nativeTransportService != null)
            nativeTransportService.destroy();
        StorageService.instance.setRpcReady(false);

        // On windows, we need to stop the entire system as prunsrv doesn't have the jsvc hooks
        // We rely on the shutdown hook to drain the node
        if (FBUtilities.isWindows)
            System.exit(0);
    }
1142841
def stop(self):
        
        if self.server.eio.async_mode == 'threading':
            func = flask.request.environ.get('werkzeug.server.shutdown')
            if func:
                func()
            else:
                raise RuntimeError('Cannot stop unknown web server')
        elif self.server.eio.async_mode == 'eventlet':
            raise SystemExit
        elif self.server.eio.async_mode == 'gevent':
            self.wsgi_server.stop()
307338
def stop(ctx, service, editable):
    """"""
    logger.debug("running command %s (%s)", ctx.command.name, ctx.params,
                 extra={"command": ctx.command.name, "params": ctx.params})

    home = ctx.obj["HOME"]
    service_path = plugin_utils.get_plugin_path(home, SERVICES, service, editable)

    logger.debug("loading {}".format(service))
    service = register_service(service_path)

    try:
        with open(os.path.join(service_path, ARGS_JSON)) as f:
            service_args = json.loads(f.read())
    except IOError as exc:
        logger.debug(str(exc), exc_info=True)
        raise click.ClickException("Cannot load service args, are you sure server is running?")

    # get our service class instance
    service_module = get_service_module(service_path)
    service_obj = service_module.service_class(alert_types=service.alert_types, service_args=service_args)

    # prepare runner
    runner = myRunner(service_obj,
                      pidfile=service_path + ".pid",
                      stdout=open(os.path.join(service_path, "stdout.log"), "ab"),
                      stderr=open(os.path.join(service_path, "stderr.log"), "ab"))

    click.secho("[*] Stopping {}".format(service.name))
    try:
        runner._stop()
    except daemon.runner.DaemonRunnerStopFailureError as exc:
        logger.debug(str(exc), exc_info=True)
        raise click.ClickException("Unable to stop service, are you sure it is running?")
157768
def stop(state, host, ctid):
    '''
    
    '''

    args = ['{0}'.format(ctid)]

    yield 'vzctl stop {0}'.format(' '.join(args))
819637
def stop(name):
    '''
    
    '''
    if _service_is_upstart(name):
        cmd = 'stop {0}'.format(name)
    else:
        cmd = '/sbin/service {0} stop'.format(name)
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
964175
private void stopProcessEngine(String serviceName, PlatformServiceContainer serviceContainer) {

    try {
      serviceContainer.stopService(serviceName);
    }
    catch(Exception e) {
      LOG.exceptionWhileStopping("Process Engine", serviceName, e);
    }

  }