Kill the Redis servers.

        Args:
            check_alive (bool): Raise an exception if any of the processes
                were already dead.
333271
def kill_redis(self, check_alive=True):
        
        self._kill_process_type(
            ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_alive)
590716
def kill(signal)
      Process.kill(signal.to_s, pid) if pid && @self_started
      @killed = true
    rescue Errno::ESRCH => e
      log "Can't kill #{pid}: #{e}"
    end
1201218
def active_processes(self, use_cache=True):
        
        LOGGER.debug('Checking active processes (cache: %s)', use_cache)
        if self.can_use_process_cache(use_cache):
            return self._active_cache[1]
        active_processes, dead_processes = list(), list()
        for consumer in self.consumers:
            processes = list(self.consumers[consumer].processes)
            for name in processes:
                child = self.get_consumer_process(consumer, name)
                if child is None:
                    dead_processes.append((consumer, name))
                elif child.pid is None:
                    dead_processes.append((consumer, name))
                    continue
                elif child.pid == self.pid:
                    continue
                try:
                    proc = psutil.Process(child.pid)
                except psutil.NoSuchProcess:
                    dead_processes.append((consumer, name))
                    continue

                if self.unresponsive[name] >= self.MAX_UNRESPONSIVE_COUNT:
                    LOGGER.info('Killing unresponsive consumer %s (%i): '
                                '%i misses',
                                name, proc.pid, self.unresponsive[name])
                    try:
                        os.kill(child.pid, signal.SIGABRT)
                    except OSError:
                        pass
                    dead_processes.append((consumer, name))
                elif self.is_dead(proc, name):
                    dead_processes.append((consumer, name))
                else:
                    active_processes.append(child)

        if dead_processes:
            LOGGER.debug('Removing %i dead process(es)', len(dead_processes))
            for proc in dead_processes:
                self.remove_consumer_process(*proc)
        self._active_cache = time.time(), active_processes
        return active_processes
829652
async def _keepalive(self):
        '''
            
        '''
        while self.protocol:
            vers = await self.RPC('server.version')
            logger.debug("Server version: " + repr(vers))

            # Five minutes isn't really enough anymore; looks like
            # servers are killing 2-minute old idle connections now.
            # But decreasing interval this seems rude.
            await asyncio.sleep(600)
978980
def stop_process(process):
    """"""
    process.terminate()
    process.join(3)

    if process.is_alive() and os.name != 'nt':
        try:
            os.kill(process.pid, signal.SIGKILL)
            process.join()
        except OSError:
            return

    if process.is_alive():
        raise RuntimeError("Unable to terminate PID %d" % os.getpid())
218136
private void checkForTermination() {
    synchronized (lock) {
      if (shutdown && transports.isEmpty() && transportServersTerminated) {
        if (terminated) {
          throw new AssertionError("Server already terminated");
        }
        terminated = true;
        channelz.removeServer(this);
        if (executor != null) {
          executor = executorPool.returnObject(executor);
        }
        lock.notifyAll();
      }
    }
  }
840553
def terminate(self, force=False):
        ''' '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
1224875
def check_workers(self):
        ''' '''
        if time.time() - self._worker_alive_time > 5:
            self._worker_alive_time = time.time()
            # join processes if they are now gone, it should not do anything bad
            # if the process is still running
            [worker.join() for worker in self._workers if not worker.is_alive()]
            self._workers = [
                worker for worker in self._workers if worker.is_alive()
            ]
            if len(self._workers) < self._num_workers:
                raise ProcessKilled('One of the workers has been killed.')
850759
def killall(self, wait = None):
        
        with self.tasks.mutex:
            self.tasks.queue.clear()
        self.count_lock.acquire()
        self.kill(self.workers)
        self.count_lock.release()
        self.kill_event.wait(wait)
722237
def turn_off
      _check_server!

      fail "Not active!" unless active?

      @detected.available.each do |obj|
        obj.turn_off if obj.respond_to?(:turn_off)
      end

      _env.notify_active = false
    end
634397
def terminate(self, signal_chain=KILL_CHAIN, kill_wait=KILL_WAIT_SEC, purge=True):
    """"""
    alive = self.is_alive()
    if alive:
      logger.debug('terminating {}'.format(self._name))
      for signal_type in signal_chain:
        pid = self.pid
        try:
          logger.debug('sending signal {} to pid {}'.format(signal_type, pid))
          self._kill(signal_type)
        except OSError as e:
          logger.warning('caught OSError({e!s}) during attempt to kill -{signal} {pid}!'
                         .format(e=e, signal=signal_type, pid=pid))

        # Wait up to kill_wait seconds to terminate or move onto the next signal.
        try:
          if self._deadline_until(self.is_dead, 'daemon to exit', timeout=kill_wait):
            alive = False
            logger.debug('successfully terminated pid {}'.format(pid))
            break
        except self.Timeout:
          # Loop to the next kill signal on timeout.
          pass

    if alive:
      raise ProcessManager.NonResponsiveProcess('failed to kill pid {pid} with signals {chain}'
                                      .format(pid=self.pid, chain=signal_chain))

    if purge:
      self.purge_metadata(force=True)
822205
def try_to_restart_deads(self):
        
        to_restart = self.to_restart[:]
        del self.to_restart[:]

        for instance in to_restart:
            logger.warning("Trying to restart module: %s", instance.name)

            if self.try_instance_init(instance):
                logger.warning("Restarting %s...", instance.name)
                # Because it is a restart, clean the module inner process reference
                instance.process = None
                # If it's an external module, it will start the process
                instance.start()
                # Ok it's good now :)
            else:
                # Will retry later...
                self.to_restart.append(instance)
710257
def __die(self, synchronous=False):
        
        if self.__id and not self.__killed:
            if self.__exhaust and self.__exhaust_mgr:
                # If this is an exhaust cursor and we haven't completely
                # exhausted the result set we *must* close the socket
                # to stop the server from sending more data.
                self.__exhaust_mgr.sock.close()
            else:
                address = _CursorAddress(
                    self.__address, self.__collection.full_name)
                if synchronous:
                    self.__collection.database.client._close_cursor_now(
                        self.__id, address)
                else:
                    self.__collection.database.client.close_cursor(
                        self.__id, address)
        if self.__exhaust and self.__exhaust_mgr:
            self.__exhaust_mgr.close()
        self.__killed = True
325244
def killall(self, wait = None):
        
        self.queue.close()
        self.count_lock.acquire()
        self.kill(self.shared['workers'])
        self.count_lock.release()
        self.tasks.close()
        self.terminate()
        self.kill_event.wait(wait)
613267
def kill_raylet_monitor(self, check_alive=True):
        
        self._kill_process_type(
            ray_constants.PROCESS_TYPE_RAYLET_MONITOR, check_alive=check_alive)
236919
def kill_plasma_store(self, check_alive=True):
        
        self._kill_process_type(
            ray_constants.PROCESS_TYPE_PLASMA_STORE, check_alive=check_alive)
33956
def running?
      Process.kill 0, @pid
      true
    rescue Errno::ESRCH
      false
    rescue Errno::EPERM
      true
    rescue
      false
    end