停止当前worker实例
@return void
349454
public function stop()
    {
        // 如果有设置进程终止回调，则执行
        if($this->onWorkerStop)
        {
            call_user_func($this->onWorkerStop, $this);
        }
        // 删除相关监听事件，关闭_mainSocket
        static::$globalEvent->del($this->_mainSocket, EventInterface::EV_READ);
        @fclose($this->_mainSocket);
    }
509978
public function shutdown()
    {
        $this->shutdown = true;
        $this->redis->hmset(self::redisKey($this), 'shutdown', true);

        Event::fire(Event::WORKER_SHUTDOWN, $this);
    }
951062
public function cancel()
    {
        $this->stopped();

        $this->setStatus(Job::STATUS_CANCELLED);

        $this->redis->zadd(Queue::redisKey($this->queue, 'cancelled'), time(), $this->payload);
        Stats::incr('cancelled', 1);
        Stats::incr('cancelled', 1, Queue::redisKey($this->queue, 'stats'));

        Event::fire(Event::JOB_CANCELLED, $this);
    }
671679
public function haltCurrentJob()
    {
        $currentJob = $this->getCurrentJob();

        if (null === $this->childProcess || !$this->childProcess->getPid()) {
            $this->getLogger()->debug('No child to kill for worker {worker}', array('worker' => $this));

            return;
        }

        $this->getLogger()->warning(
            'Worker {worker} killing active child {childPid}',
            array(
                'worker' => $this,
                'childProcess' => $this->childProcess,
                'childPid' => $this->childProcess->getPid()
            )
        );

        $this->childProcess->kill();

        if (null !== $currentJob) {
            $this->handleFailedJob(
                $currentJob,
                new DirtyExitException(
                    sprintf(
                        'Worker %s forcibly killed job %s due to halt',
                        $this,
                        $currentJob->getId()
                    )
                )
            );
        }
    }
480170
public function stop()
    {

        // load the queue keys
        $queues = get_object_vars($this->getQueues());

        // iterate over the queues and shut them down
        /** @var AppserverIo\Psr\Pms\QueueInterface $queue */
        foreach ($queues as $queue) {
            $queue->stop();
        }
    }
840451
public function stop()
    {
        $this->setStop(true);
        foreach ($this->getWatches() as $watch) {
            $watch->stop();
        }
    }
1111530
protected function stopWorkerPools() : bool
    {
        if (empty($this->processes)) {
            return true;
        }
        foreach (array_keys($this->processes) as $poolName) {
            $this->stopWorkerPool($poolName);
        }
        return true;
    }
500073
public static function shutdown()
    {
        self::$msgOutputLevel = Project::MSG_INFO;
        self::restoreIni();
        self::getTimer()->stop();
    }
405424
public function shutdownHandler()
    {
        $lastError = error_get_last();

        if (is_array($lastError)) {
            $this->errorHandler(
                $lastError[ 'type' ],
                $lastError[ 'message' ],
                $lastError[ 'file' ],
                $lastError[ 'line' ]
            );
        }
    }
1367952
public function stop()
  {
    $this->end = microtime(true);
    return bcsub($this->end, $this->start, 2);
  }
111698
def stop(self):
        """"""
        self.working = False
        for w in self.workers:
            w.join()
        self.workers = []
700500
public function stop()
    {
        if (!$this->running) {
            return;
        }

        $this->running = false;

        $promise = call(function () {
            $promises = [];
            foreach (clone $this->workers as $worker) {
                \assert($worker instanceof Internal\IpcParent);
                $promises[] = call(function () use ($worker) {
                    list($process, $promise) = $this->workers[$worker];
                    \assert($process instanceof Process);

                    try {
                        yield $worker->shutdown();
                        yield Promise\timeout($promise, self::WORKER_TIMEOUT);
                    } catch (ContextException $exception) {
                        // Ignore if the worker has already died unexpectedly.
                    } finally {
                        if ($process->isRunning()) {
                            $process->kill();
                        }
                    }
                });
            }

            list($exceptions) = yield Promise\any($promises);

            $this->workers = new \SplObjectStorage;

            if (!empty($exceptions)) {
                $exception = new MultiReasonException($exceptions);
                $message = \implode('; ', \array_map(function (\Throwable $exception): string {
                    return $exception->getMessage();
                }, $exceptions));
                throw new ClusterException("Stopping the cluster failed: " . $message, 0, $exception);
            }
        });

        $this->deferred->resolve($promise);
    }
1118268
protected static function exitAndClearAll()
    {
        foreach (self::$_workers as $worker) {
            $socket_name = $worker->getSocketName();
            if ($worker->transport === 'unix' && $socket_name) {
                list(, $address) = explode(':', $socket_name, 2);
                @unlink($address);
            }
        }
        @unlink(self::$pidFile);
        self::log("Workerman[" . basename(self::$_startFile) . "] has been stopped");
        if (self::$onMasterStop) {
            call_user_func(self::$onMasterStop);
        }
        exit(0);
    }
887822
public function cancelTask()
	{
		// Set the redirect
		\App::redirect(
			\Route::url('index.php?option=' . $this->_option . ($this->_controller ? '&controller=' . $this->_controller : ''), false)
		);
	}
785379
public function (): void
    {
        $local_pids = $this->getLocalWorkerPids();
        $workers = $this->getAllWorkerIds();

        foreach ($workers as $worker) {
            [$host, $pid] = explode(':', $worker, 3);

            if ($host !== $this->hostname || in_array($pid, $local_pids, false) || $pid === getmypid()) {
                continue;
            }
            $this->log->debug(sprintf('Pruning dead worker: %s', $worker));

            $this->unregisterWorker($worker);
        }
    }
531443
function stop(){
		if( $this->is_running() ){
			$this->stopped = microtime( false );
			return $this->milliseconds();
		}
		else{
			trigger_error("Timer already stopped", E_USER_NOTICE);
			return false;
		}
	 }
423805
protected static function lock()
    {
        $fd = fopen(static::$_startFile, 'r');
        if (!$fd || !flock($fd, LOCK_EX)) {
            static::log("Workerman[".static::$_startFile."] already running");
            exit;
        }
    }