finishedWorking

@param \QueueJitsu\Worker\AbstractWorker $worker
341443
public function finishedWorking(AbstractWorker $worker): void
    {
        $this->adapter->increaseProcessedCount();
        $this->adapter->increaseWorkerProcessedCount($worker);
        $this->adapter->clearTaskData($worker);
    }
889610
protected function work(): void
    {
        if (@$this->worker->work()
            || $this->worker->returnCode() == GEARMAN_IO_WAIT
            || $this->worker->returnCode() == GEARMAN_NO_JOBS
        ) {
            if ($this->worker->returnCode() == GEARMAN_SUCCESS) {
                return;
            }

            if (!@$this->worker->wait()) {
                if ($this->worker->returnCode() == GEARMAN_NO_ACTIVE_FDS) {
                    sleep(5);
                }
            }
        }
    }
354008
protected function workInBackground(InputInterface $input): void
    {
        $worker_count = $input->getOption('workers');

        for ($i = 0; $i < $worker_count; ++$i) {
            $pid = pcntl_fork();

            if ($pid === -1) {
                die(sprintf("Could not fork worker %d\n", $i));
            }

            if (!$pid) {
                $pidfile = $input->getOption('pidfile');
                if ($pidfile && $i === 0) {
                    $this->writePidFile($pidfile);
                }

                $worker_factory = $this->worker_factory;

                /** @var array $queues */
                $queues = $input->getArgument('queues');

                /** @var \QueueJitsu\Worker\Worker $worker */
                $worker = $worker_factory($queues);

                $worker($input->getOption('interval'));
                break;
            }
        }
    }
1254769
protected static function forkOneWorkerForLinux($worker)
    {
        // Get available worker id.
        $id = static::getId($worker->workerId, 0);
        if ($id === false) {
            return;
        }
        $pid = pcntl_fork();
        // For master process.
        if ($pid > 0) {
            static::$_pidMap[$worker->workerId][$pid] = $pid;
            static::$_idMap[$worker->workerId][$id]   = $pid;
        } // For child processes.
        elseif (0 === $pid) {
            srand();
            mt_srand();
            if ($worker->reusePort) {
                $worker->listen();
            }
            if (static::$_status === static::STATUS_STARTING) {
                static::resetStd();
            }
            static::$_pidMap  = array();
            // Remove other listener.
            foreach(static::$_workers as $key => $one_worker) {
                if ($one_worker->workerId !== $worker->workerId) {
                    $one_worker->unlisten();
                    unset(static::$_workers[$key]);
                }
            }
            Timer::delAll();
            static::setProcessTitle('WorkerMan: worker process  ' . $worker->name . ' ' . $worker->getSocketName());
            $worker->setUserAndGroup();
            $worker->id = $id;
            $worker->run();
            $err = new Exception('event-loop exited');
            static::log($err);
            exit(250);
        } else {
            throw new Exception("forkOneWorker fail");
        }
    }
254630
public function onFinish(Server $server, int $taskId, $data): void
    {
        $this->log("task finished on the task worker. status: $data", [
            'taskId'   => $taskId,
            'workerId' => $server->worker_id,
        ], 'debug');
    }
871255
public function cleanUp()
    {
        // create a separate queue for each priority
        foreach (PriorityKeys::getAll() as $priorityKey) {
            $this->workers[$this->uniqueWorkerName($priorityKey)]->stop();
        }
    }
407872
public function addWorker($worker)
    {
        if (!$worker instanceof Worker) {
            throw new \Exception('$worker is not an instance of Worker');
        }
        $this->workerList[$worker->getId()] = $worker;

        return $this;
    }
151899
public function finish() {
        $this->runUpdate(
            "DELETE FROM " . self::$jobsTable . " WHERE id = ?",
            array($this->job_id)
        );
        $this->log("[JOB] completed job::{$this->job_id}", self::INFO);
    }
285776
public function finishProcessing(\ArrayObject $jobs)
    {
        foreach ($jobs as $job) {
            $job->setStatus(JobInterface::STATUS_ACTIVE);
        }

        $this->em->flush();

        return $this;
    }
884224
public function terminate($status = 0)
    {
        $this->working = false;

        // We will mark this supervisor as terminating so that any user interface can
        // correctly show the supervisor's status. Then, we will scale the process
        // pools down to zero workers to gracefully terminate them all out here.
        app(SupervisorRepository::class)->forget($this->name);

        $this->processPools->each(function ($pool) {
            $pool->processes()->each(function ($process) {
                $process->terminate();
            });
        });

        if ($this->shouldWait()) {
            while ($this->processPools->map->runningProcesses()->collapse()->count()) {
                sleep(1);
            }
        }

        $this->exit($status);
    }
1033537
public function getLowLoadedWorker(AbstractThread $thread): Worker
    {
        $selectedWorker = null;
        foreach ($this->workerPool as $worker) {
            /**
             * @var $worker Worker
             */
            if ($worker->getState() === Worker::STOP || !$worker->isThreadKnow($thread)) {
                // не знает такую задачу
                continue;
            }
            if (!isset($count)) {
                $count = $worker->getCountRunThreads();
                $selectedWorker = $worker;
            } elseif ($count > ($newCount = $worker->getCountRunThreads())) {
                $count = $newCount;
                $selectedWorker = $worker;
            }
        }
        if (is_null($selectedWorker)) {
            throw new \RuntimeException('Cannot select worker.');
        }

        return $selectedWorker;
    }
1020528
protected function execute(
        InputInterface $input,
        OutputInterface $output
    ) {
        $this->initialiseWorker($input, $output);
        $this->verboseOutput("<info>Starting up</info>");
        while ($this->keepWorking) {
            //do stuff
            //check if the processes are still working
            foreach ($this->family as $key => &$child) {
                $this->handle($key, $child);
            }
            $this->familyPlanning();
            //go to sleep for a bit
            usleep(100000);
        }
        $this->verboseOutput("<info>DONE!</info>");
    }
423415
private function waitForAllToFinish(): void
    {
        do {
            foreach ($this->workers as $key => $worker) {
                if (!$worker->isRunning()) {
                    unset($this->workers[$key]);
                }
            }
            usleep(10000);
            $this->printOutput();
        } while (\count($this->workers) > 0);
    }
1205432
function finalize () {
  stats.stop()
  if (argv.summary === true && rwWorkers > 0) {
    return stats.reportFinal(argv, console.log)
  }
}
1065958
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->initialiseWorker($input, $output);
        $timePeriod = $input->getOption('period');
        $this->taskQueueService->cleanUpTasks($timePeriod);
    }
187284
protected function worker()
    {
        // Bootstrap
        $this->addLogging();

        // Run this stuff as long as the worker is running
        while (true) {
            $this->fire();
            Cache::forever($this->HEARTBEAT_WORKER_KEY, time());
            sleep($this->WORKER_SLEEP_SECS);
        }
    }
516536
function completeJob(loader, job, callback) {
    var nextJob;

    loader.jobsInProgress--;

    if ((!loader.jobLimit || loader.jobsInProgress < loader.jobLimit) && loader.jobQueue.length > 0) {
        nextJob = loader.jobQueue.shift();
        nextJob.start();
        loader.jobsInProgress++;
    }

    callback(job.image, job.errorMsg, job.request);
}