Perform a monitor loop.

@return void
340723
public function loop()
    {
        try {
            $this->processPendingSignals();

            $this->processPendingCommands();

            if ($this->working) {
                $this->monitorSupervisors();
            }

            $this->persist();

            event(new MasterSupervisorLooped($this));
        } catch (Exception $e) {
            app(ExceptionHandler::class)->report($e);
        } catch (Throwable $e) {
            app(ExceptionHandler::class)->report(new FatalThrowableError($e));
        }
    }
1193650
public function check() : void {
        $processesInfo = $this->getProcessesInfo();

        foreach($this->processes as $process) {
            foreach($processesInfo as $processInfo) {
                if( Str::startsWith($processInfo->getCommand(), $process->getCommand()) ) {
                    $process->setInfo($processInfo);
                    break 2;
                }
            }
        }

        $this->checked = true;
    }
979976
protected function checkPause()
    {
        parent::checkPause();

        foreach ($this->slaves as $slave) {
            $this->checkSlave($slave);
        }
    }
608144
public function trigger()
    {
        $this->trace = debug_backtrace();

        $this->reporter = get_class($this);
        if (isset($this->trace[$this->offset]['class'])) {
            $this->reporter = $this->trace[$this->offset]['class'];
        }

        if (isset($this->trace[$this->offset]['file'])) {
            $this->file = $this->trace[$this->offset]['file'];
        }

        if (isset($this->trace[$this->offset]['line'])) {
            $this->line = $this->trace[$this->offset]['line'];
        }

        if (!empty($this->variables)) {
            $this->message = vsprintf($this->message, $this->variables);
            $this->variables = array();
        }

        throw $this;
    }
343706
public function start()
    {
        $command = $this->client->createCommand('MONITOR');
        $this->client->executeCommand($command, $this);
    }
1349850
public function main() {
        $this->stdout->styles('success', array('text' => 'green'));

        $this->hr(1);
        $this->out(sprintf('%s Steps:', $this->name));

        $counter = 1;

        foreach ($this->steps as $method) {
            $this->steps($counter);

            try {
                if (!call_user_func(array($this, $method))) {
                    $this->err('<error>Process aborted!</error>');
                    break;
                }
            } catch (Exception $e) {
                $this->err(sprintf('<error>Unexpected error has occurred; %s</error>', $e->getMessage()));
                break;
            }

            $counter++;
        }
    }
1250495
public function executed()
    {
        $this->setLastRun(new \DateTime());
        if (!$this->getModify()) {
            $this->setStatus(self::STATUS_DISABLED);
        }
        if ($this->getStatus() == self::STATUS_ENABLED) {
            // find near time task launch
            $next_run = $this->getNextRun();
            do {
                // failed to compute time of next run
                if ($next_run->modify($this->getModify()) === false) {
                    $this->setModify('');
                    $this->setStatus(self::STATUS_DISABLED);
                    break;
                }
            } while ($next_run->getTimestamp() <= time());
            $this->setNextRun($next_run);
        }
    }
315700
public function run()
    {
        try {
            $this->loop->run();
        } catch (WorkerException $e) {
            $this->logger->error('Worker Error: ' . $e->getMessage());
        }
    }
4004
public function tick()
    {
        while (!$this->queue->isEmpty() && $this->loop->isRunning())
        {
            $this->callback = $this->queue->dequeue();
            $callback = $this->callback; // without this proxy PHPStorm marks line as fatal error.
            $callback($this->loop);
        }
    }
17072
protected function monitorSupervisors()
    {
        $this->supervisors->each->monitor();

        $this->supervisors = $this->supervisors->reject->dead;
    }
170198
public function main()
    {

        // log the configured deployment directory
        $this->getSystemLogger()->debug(
            sprintf(
                "Start watching heartbeat file %s",
                $this->getHeartbeatFile()
            )
        );

        // wait until the server has been successfully started at least once
        while ($this->getLastFileTouch($this->getHeartbeatFile()) === 0) {
            $this->getSystemLogger()->debug('Heartbeat scanner is waiting for first successful startup ...');
            sleep(1);
        }

        // watch the heartbeat file
        while (true) {
            // load the current file change time of the heartbeat file and store it
            $oldMTime = $this->getLastFileTouch($this->getHeartbeatFile());

            // Get the current time
            $currentTime = time();

            // log the found directory hash value
            $this->getSystemLogger()->debug(
                sprintf(
                    "Comparing heartbeat mTimes %s (previous) : %s (actual)",
                    $oldMTime,
                    $currentTime
                )
            );

            // compare the mTime values, if they differ more than allowed we have to take action
            if (($currentTime - $oldMTime) > self::HEARTBEAT_INTERVAL) {
                // log that changes have been found
                $this->getSystemLogger()->debug(
                    sprintf(
                        "Found heartbeat missing for %s seconds.",
                        $currentTime - $oldMTime
                    )
                );

                // as long as the heartbeat does not come back up we will try to restart the appserver
                while ($oldMTime === $this->getLastFileTouch($this->getHeartbeatFile())) {
                    // tell them we try to restart
                    $this->getSystemLogger()->debug("Will try to restart the appserver.");

                    // restart the appserver
                    $this->restart();

                    // wait until restart has been finished, but only wait for so long
                    for ($i = 0; $i <= self::RESTART_INTERVAL; $i ++) {
                        // sleep a little
                        sleep(1);
                    }
                }

                // log that the appserver has been restarted successfully
                $this->getSystemLogger()->debug("appserver has successfully been restarted.");

            } else {
                // if no changes has been found, wait a second
                sleep(1);
            }
        }
    }
1066832
public function performCheck()
    {
        $this->emailCheck($this->getEmailSendCheck(), self::EMAIL_SEND_CHECK_MSG);
        $this->emailCheck($this->getEmailReceiveCheck(), self::EMAIL_RECEIVE_CHECK_MSG);
    }
1141012
function watch(): Result {
    $this->build();
    return $this->taskWatch()
      ->monitor('lib', function() { $this->build(); })
      ->monitor('test', function() { $this->test(); })
      ->run();
  }
1032010
protected function _execute()
    {
        if (!$this->enabled() && !$this->focused()) {
            return;
        }
        foreach ($this->_children as $child) {
            if ($this->suite()->failfast()) {
                break;
            }
            $this->_passed = $child->process() && $this->_passed;
        }
    }
39372
public function process()
    {
        parent::process();

        if ($this->show_check_all) {
            $this->check_all->process();
        }

        // this is part of the old selection API
        $item_name = $this->getCheckboxRendererId();
        if (isset($_POST[$item_name]) && is_array($_POST[$item_name])) {
            $this->items = $_POST[$item_name];
        }
    }
1334190
public function run(): void
    {
        $this->connectionManager->listen();

        while ($this->loop->shouldContinue()) {
            /*
             * If there's nothing changed on any of the sockets, the server
             * will sleep and other processes will have a change to run. Control
             * this behaviour with the timeout options.
             */
            $this->connectionManager->selectAndProcess();

            /*
             * If the application wants to perform periodic operations or queries
             * and push updates to clients based on the result then that logic can
             * be implemented in the 'onUpdate' method.
             */
            foreach ($this->applications as $application) {
                if (method_exists($application, 'onUpdate')) {
                    $application->onUpdate();
                }
            }
        }
    }
647600
public function start() {
        if ($this->watcher !== null) {
            return;
        }

        $this->watcher = Loop::repeat($this->checkInterval, function () {
            // Use double defer to calculate complete tick time
            // instead of timer → defer time.
            Loop::unreference(Loop::defer($this->check));
        });

        Loop::unreference($this->watcher);
    }