Stop service
@param string $instance Specify "current" or "old". "current" by default.
347504
public function stop($instance = 'current')
    {
        // Get (current or old) service info
        if ($serviceInfo = $this->getServiceInfo($instance)) {
            list($pid, $managerPid, $port) = array_values($serviceInfo);
            // Get serving connection numbers
            $connections = $this->sendCommand('connections', $port, $error);

            // Wait while all connections are served
            // @codeCoverageIgnoreStart
            while (!$error && $connections > 0) {
                usleep(5e5);
                $connections = $this->sendCommand('connections', $port, $error);
            }
            // @codeCoverageIgnoreEnd

            // Send TERM signal to master process to stop service
            posix_kill($pid, SIGTERM);

            // Kill master process in Mac OS
            // @codeCoverageIgnoreStart
            if (PHP_OS == 'Darwin') {
                sleep(1);
                posix_kill($pid, SIGKILL);
            }
            // @codeCoverageIgnoreEnd
        }
        $this->cliOutput('info', 'Service stopped.');
    }
1234506
public function instance($instance = null)
    {
        $instance = $instance ?: self::DEFAULT_INSTANCE;

        $this->instance = sprintf('%s.%s', 'cart', $instance);

        return $this;
    }
1200249
def stop(self):
        
        # Exit the loop
        with self._lock:
            self._stop_event.set()
            self._shell_event.clear()

        if self._context is not None:
            # Unregister from events
            self._context.remove_service_listener(self)

            # Release the shell
            self.clear_shell()
            self._context = None
427587
public static void stop(Service service) {
    if (service != null) {
      Service.STATE state = service.getServiceState();
      if (state == Service.STATE.STARTED) {
        service.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?")
359040
public function stopDatabase($database)
    {
        assert($this->_platform instanceof SQLAnywherePlatform);
        $this->_execSql($this->_platform->getStopDatabaseSQL($database));
    }
1345059
public function close(?string $connection = null): void
	{
		$connection = $connection ?? $this->default;

		if(isset($this->connections[$connection]))
		{
			if(method_exists($this->connections[$connection], 'close'))
			{
				// Call close on the connection object in case there's a reference
				// to the connection that won't be garbage collected immediately

				$this->connections[$connection]->close();
			}

			unset($this->connections[$connection]);
		}
	}
838725
def do_stopInstance(self,args):
        """"""
        parser = CommandArgumentParser("stopInstance")
        parser.add_argument(dest='instance',help='instance index or name');
        parser.add_argument('-f','--force',action='store_true',dest='force',help='instance index or name');
        args = vars(parser.parse_args(args))

        instanceId = args['instance']
        force = args['force']
        try:
            index = int(instanceId)
            instances = self.scalingGroupDescription['AutoScalingGroups'][0]['Instances']
            instanceId = instances[index]
        except ValueError:
            pass

        client = AwsConnectionFactory.getEc2Client()
        client.stop_instances(InstanceIds=[instanceId['InstanceId']],Force=force)
488717
@Override
    public void stop(){
        if (isStarted) {
            synchronized (this) {
                if (isStarted) {
                    if (getRegistrationService() instanceof Closable) {
                        ((Closable) getRegistrationService()).stop();
                    }
                    isStarted = false;
                }
            }
        }

    }
1342114
protected function terminate($context)
    {
        $handler = $context->getMessageHandler();
        $handler->handle($context->getMessageBeingHandled(), $context);
    }
443353
def stop_all(self):
        """"""
        for alias, service in self._service_objects.items():
            if service.is_alive:
                with expects.expect_no_raises(
                        'Failed to stop service "%s".' % alias):
                    service.stop()
984615
protected function stop($name)
    {
        if (array_key_exists($name, $this->started)) {
            $this->timers[] = [
                'event' => $name,
                'time' => microtime(true) - $this->started[$name],
            ];
        }
    }
69605
public function can_delete_instance($instance) {
        $context = context_course::instance($instance->courseid);
        if (!has_capability('enrol/ldap:manage', $context)) {
            return false;
        }

        if (!enrol_is_enabled('ldap')) {
            return true;
        }

        if (!$this->get_config('ldap_host') or !$this->get_config('objectclass') or !$this->get_config('course_idnumber')) {
            return true;
        }

        // TODO: connect to external system and make sure no users are to be enrolled in this course
        return false;
    }
16754
public static function stop()
    {

        //Get usage data
        $now = microtime(true);
        $speed = number_format(1000 * ($now - static::$time), 2);
        $_memory = memory_get_usage();
        $units = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB');
        $memory = @round($_memory / pow(1024, ($i = floor(log($_memory, 1024)))), 2) . ' ' . $units[$i];
        $queries = '0';
        //Get Query usage
        //@TODO this smells, a method to detect that the database has been installed;
        $installed = (bool)\Library\Config::getParam("installed", FALSE, "database");

        if ($installed):

            $database = \Library\Database::getInstance();
            $queries = $database->getTotalQueryCount();

        endif;

        //Log usage
        self::log($now, _t("Stop execution time"), "info");

        $output = \Library\Output::getInstance();
        $showMessage = \Library\Config::getParam("mode", 1, "environment");
        if ((int)$showMessage < 2) {
            $output = \Library\Output::getInstance();
            $output->set("debug", array("displaylog" => true));
            $output->set("debug", array("queries" => $queries));
            $output->set("debug", array("log" => static::$log));
        }
        //Set the debugger output
        $output->set("debug", array("start" => static::$time));
        $output->set("debug", array("stop" => $now));
        $output->set("debug", array("speed" => $speed));
        $output->set("debug", array("memory" => $memory));

        //Library\Date::difference($now, $speed);
        //print_R(static::getInstance());


    }
755988
public function stop()
    {
        if (!$this->started) {
            throw new Exception\ConnectionException('Client is not started');
        }

        if ($this->browserAutoruned) {
            $this->con->stop();
        }

        $this->started = false;
    }
1091676
def stop(self):
        

        instance_status = Instance.InstanceStatus(status='Terminated')
        xml_content = instance_status.serialize()

        headers = {'Content-Type': 'application/xml'}
        self._client.put(self.resource(), xml_content, headers=headers)
709438
def stop(self, instances, count=0):
        
        if not instances:
            return
        if count > 0:
            instances = self._scale_down(instances, count)
        self.ec2.stop_instances([i.id for i in instances])