Return cron list and status.

@return EdgarCron[] cron list with status
420726
public function listCronsStatus(): array
    {
        /** @var EdgarCron[] $edgarCrons */
        $edgarCrons = $this->repository->listCrons();
        /** @var CronInterface[] $crons */
        $crons = $this->getCrons();
        $cronAlias = [];

        foreach ($crons as $cron) {
            $cronAlias[$cron->getAlias()] = $cron;
        }

        if ($edgarCrons) {
            foreach ($edgarCrons as $edgarCron) {
                if (isset($cronAlias[$edgarCron->getAlias()])) {
                    $cronAlias[$edgarCron->getAlias()] = $edgarCron;
                }
            }
        }

        return $cronAlias;
    }
476735
public static function getStatusList()
    {
        return [
            self::STATUS_OPEN => 'status_open',
            self::STATUS_PENDING => 'status_pending',
            self::STATUS_VALIDATED => 'status_validated',
            self::STATUS_CANCELLED => 'status_cancelled',
            self::STATUS_ERROR => 'status_error',
            self::STATUS_STOPPED => 'status_stopped',
        ];
    }
967234
public static function getStateOfWorkers()
    {
        $offset = 0;

        $stat = [
            'idle' => 0,
            'busy' => 0,
            'alive' => 0,
            'shutdown' => 0,
            'preinit' => 0,
            'init' => 0,
            'reloading' => 0,
        ];
        $readed = 0;
        while (($buf = Daemon::$shm_wstate->read($readed, 1024)) !== false) {
            $buflen = mb_orig_strlen($buf);
            $readed += $buflen;
            for ($i = 0; $i < $buflen; ++$i) {
                $code = ord($buf[$i]);
                if ($code >= 100) {
                    // reloaded (shutdown)
                    $code -= 100;
                    if ($code !== Daemon::WSTATE_SHUTDOWN) {
                        ++$stat['alive'];
                        if (Daemon::$process instanceof Thread\Master) {
                            Daemon::$process->reloadWorker($offset + $i + 1);
                            ++$stat['reloading'];
                            continue;
                        }
                    }
                }
                if ($code === Daemon::WSTATE_IDLE) {
                    // idle
                    ++$stat['alive'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_BUSY) {
                    // busy
                    ++$stat['alive'];
                    ++$stat['busy'];
                } elseif ($code === Daemon::WSTATE_SHUTDOWN) {
                    // shutdown
                    ++$stat['shutdown'];
                } elseif ($code === Daemon::WSTATE_PREINIT) {
                    // pre-init
                    ++$stat['alive'];
                    ++$stat['preinit'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_INIT) { // init
                    ++$stat['alive'];
                    ++$stat['init'];
                    ++$stat['idle'];
                }
            }
        }
        return $stat;
    }
1311546
public function getStatuses()
    {
        $statuses = &gplcart_static('order.statuses');

        if (isset($statuses)) {
            return $statuses;
        }

        $statuses = array(
            'pending' => $this->translation->text('Pending'),
            'canceled' => $this->translation->text('Canceled'),
            'delivered' => $this->translation->text('Delivered'),
            'completed' => $this->translation->text('Completed'),
            'processing' => $this->translation->text('Processing'),
            'dispatched' => $this->translation->text('Dispatched'),
            'pending_payment' => $this->translation->text('Awaiting payment')
        );

        $this->hook->attach('order.statuses', $statuses, $this);
        return $statuses;
    }
176020
private function getScheduleThreshold()
    {
        $hour = $this->app['config']->get('general/cron_hour', '03:00');

        if (is_numeric($hour)) {
            $hour .= ':00';
        }

        $this->cronHour = new \DateTime($hour);
    }
127304
public function status() : array
    {
        $serverPid = $this->getServerPid();
        if (empty($serverPid)) {
            throw new ControlException('Angela not currently running.');
        }
        $response = $this->sendCommand('status');
        if (empty($response)) {
            throw new ControlException('Error fetching status. (Incorrect response)');
        }
        return json_decode($response, true);
    }
593730
public function process()
    {
        $em = $this->getEm();
        $cronRegistry = $this->getCronjobs();
        $pending = $this->getPending();
        $scheduleLifetime = $this->scheduleLifetime * 60; //convert min to sec

        $now = new \DateTime;
        foreach ($pending as $job) {
            $scheduleTime = $job->getScheduleTime();

            if ($scheduleTime > $now) {
                continue;
            }

            try {
                $errorStatus = Mapper\Cronjob::STATUS_ERROR;

                $missedTime = clone $now;
                $timestamp = $missedTime->getTimestamp();
                $timestamp -= $scheduleLifetime;
                $missedTime->setTimestamp($timestamp);

                if ($scheduleTime < $missedTime) {
                    $errorStatus = Mapper\Cronjob::STATUS_MISSED;
                    throw new Exception\RuntimeException(
                        'too late for job'
                    );
                }

                $code = $job->getCode();

                if (!isset($cronRegistry[$code])) {
                    throw new Exception\RuntimeException(sprintf(
                        'job "%s" undefined in cron registry',
                        $code
                    ));
                }

                if (!$this->tryLockJob($job)) {
                    //another cron started this job intermittently. skip.
                    continue;
                }

                //run job now
                $callback = $cronRegistry[$code]['callback'];
                $args = $cronRegistry[$code]['args'];

                $job->setExecuteTime(new \DateTime);
                $em->persist($job);
                $em->flush();

                call_user_func_array($callback, $args);

                $job
                    ->setStatus(Mapper\Cronjob::STATUS_SUCCESS)
                    ->setFinishTime(new \DateTime);

            } catch (\Exception $e) {
                $job
                    ->setStatus($errorStatus)
                    ->setErrorMsg($e->getMessage())
                    ->setStackTrace($e->getTraceAsString());
            }

            $em->persist($job);
            $em->flush();
        }

        return $this;
    }
45637
private function getScheduleHours()
    {
        if (!$this->scheduleHours) {
            $jsonHelper          = new JSONHelper();
            $hoursString         = $this->contactClient->getScheduleHours();
            $this->scheduleHours = $jsonHelper->decodeArray($hoursString, 'ScheduleHours');
        }

        return $this->scheduleHours;
    }
1130305
public function schedule()
    {
        $em = $this->getEm();
        $pending = $this->getPending();
        $exists = array();
        foreach ($pending as $job) {
            $identifier = $job->getCode();
            $identifier .= $job->getScheduleTime()->getTimeStamp();
            $exists[$identifier] = true;
        }

        $scheduleAhead = $this->getScheduleAhead() * 60;

        $cronRegistry = $this->getCronjobs();

        foreach ($cronRegistry as $code => $item) {
            $now = time();
            $timeAhead = $now + $scheduleAhead;

            for ($time = $now; $time < $timeAhead; $time += 60) {
                $scheduleTime = new \DateTime();
                $scheduleTime->setTimestamp($time);
                $scheduleTime->setTime(
                    $scheduleTime->format('H'),
                    $scheduleTime->format('i')
                );
                $scheduleTimestamp = $scheduleTime->getTimestamp();

                $identifier = $code . $scheduleTimestamp;
                if (isset($exists[$identifier])) {
                    //already scheduled
                    continue;
                }

                $job = new Entity\Cronjob;
                if ($this->matchTime(
                    $scheduleTimestamp,
                    $item['frequency']
                )) {
                    $job
                        ->setCode($code)
                        ->setStatus(Mapper\Cronjob::STATUS_PENDING)
                        ->setCreateTime(new \DateTime)
                        ->setScheduleTime($scheduleTime);
                    $em->persist($job);
                    $exists[$identifier] = true;
                }
            }
        }

        $em->flush();

        return $this;
    }
925147
public function getStatus()
    {
        $reports = [];
        $solrConnections = GeneralUtility::makeInstance(ConnectionManager::class)->getAllConnections();

        foreach ($solrConnections as $solrConnection) {
            $adminService = $solrConnection->getAdminService();
            if ($adminService->ping()) {
                $installationStatus = $this->checkPluginInstallationStatus($adminService);
                $versionStatus = $this->checkPluginVersion($adminService);

                if (!is_null($installationStatus)) {
                    $reports[] = $installationStatus;
                }

                if (!is_null($versionStatus)) {
                    $reports[] = $versionStatus;
                }
            }
        }

        return $reports;
    }
327945
public function getOrderStatus()
    {
        $statuses = $this->getDoctrine()->getRepository(self::$orderStatusEntityName)->findAll();
        $locale = $this->getUser()->getLocale();
        $statusArray = [];

        foreach ($statuses as $statusEntity) {
            $status = new OrderStatus($statusEntity, $locale);
            $statusArray[] = array(
                'id' => $status->getId(),
                'status' => $status->getStatus()
            );
        }
        return $statusArray;
    }
899054
public function status() : array
    {
        $this->reloadPids();

        $workerStatus = [];
        if (empty($this->pids)) {
            return $workerStatus;
        }

        $Client = new \GearmanClient();
        $Client->addServer($this->gearmanHost, $this->gearmanPort);
        $Client->setTimeout(1000);
        foreach ($this->pids as $pool => $workerPids) {
            $workerStatus[$pool] = [];
            foreach ($workerPids as $workerName => $workerPid) {
                // raises php warning on timeout so we need the "evil @" here...
                $workerStatus[$pool][$workerName] = false;
                $start = microtime(true);
                $pong = @$Client->doHigh('ping_'.$workerName, 'ping');
                if ($pong === 'pong') {
                    $jobinfo = @$Client->doHigh('jobinfo_'.$workerName, 'foo');
                    $jobinfo = json_decode($jobinfo, true);
                    $workerStatus[$pool][$workerName] = $jobinfo;
                    $pingtime = microtime(true) - $start;
                    $workerStatus[$pool][$workerName]['ping'] = $pingtime;
                    $workerStatus[$pool][$workerName]['status'] = 'idle';
                } else {
                    $workerStatus[$pool][$workerName]['jobs_total'] = 'n/a';
                    $workerStatus[$pool][$workerName]['avg_jobs_min'] = 'n/a';
                    $workerStatus[$pool][$workerName]['uptime_seconds'] = 0;
                    $workerStatus[$pool][$workerName]['ping'] = 0;
                    $workerStatus[$pool][$workerName]['status'] = 'busy';
                }
            }
        }

        return $workerStatus;
    }
1259388
public function getCronLastExecution()
    {

        $date = $this->escapeHtml($this->helper->getDateLastCronRun('ddg_automation_importer'));

        if (! $date) {
            $date = '<span class="message message-error">No cron found</span>';
        }
        return $date;
    }
558465
public function listAction()
    {
        $this->performAccessChecks();

        $crons = $this->cronService->getCrons();

        return $this->render('SmileEzUICronBundle:cron:tab/crons/list.html.twig', [
            'datas' => $crons
        ]);
    }
1346863
public function listJobs($crontab){

        $process = new Process($this->crontabCommand($crontab).' -l');
        $process->run();

        $this->error = $process->getErrorOutput();
        return $process->getOutput();

    }
651695
public function findAll()
    {
        try {
            // initialize the array with the CRON instances
            $cronInstances = array();

            // load the service necessary to validate CRON configuration files
            /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
            $configurationService = $this->newService('AppserverIo\Appserver\Core\Api\ConfigurationService');

            // load the base CRON configuration file
            $baseCronPath = $this->getConfdDir('cron.xml');

            // we will need to test our CRON configuration files
            $configurationService->validateFile($baseCronPath, null);

            // validate the base CRON file and load it as default if validation succeeds
            $cronInstance = new CronNode();
            $cronInstance->initFromFile($baseCronPath);

            // iterate over all jobs to configure the directory where they has to be executed
            /** @var \AppserverIo\Appserver\Core\Api\Node\JobNodeInterface $jobNode */
            foreach ($cronInstance->getJobs() as $job) {
                // load the execution information
                $execute = $job->getExecute();
                // query whether or not a base directory has been specified
                if ($execute && $execute->getDirectory() == null) {
                    // set the directory where the cron.xml file located as base directory, if not
                    $execute->setDirectory(dirname($baseCronPath));
                }
            }

            // add the default CRON configuration
            $cronInstances[] = $cronInstance;

            // iterate over the configured containers
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */
            foreach ($this->getSystemConfiguration()->getContainers() as $containerNode) {
                // iterate over all applications and create the CRON configuration
                foreach (glob($this->getWebappsDir($containerNode) . '/*', GLOB_ONLYDIR) as $webappPath) {
                    // iterate through all CRON configurations (cron.xml), validate and merge them
                    foreach ($this->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF/cron')) as $cronFile) {
                        try {
                            // validate the file, but skip it if validation fails
                            $configurationService->validateFile($cronFile, null);

                            // load the system properties
                            $properties = $this->getSystemProperties($containerNode);

                            // append the application specific properties
                            $properties->add(SystemPropertyKeys::WEBAPP, $webappPath);
                            $properties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath));

                            // create a new CRON node instance and replace the properties
                            $cronInstance = new CronNode();
                            $cronInstance->initFromFile($cronFile);
                            $cronInstance->replaceProperties($properties);

                            // append it to the other CRON configurations
                            $cronInstances[] = $cronInstance;

                        } catch (ConfigurationException $ce) {
                            // load the logger and log the XML validation errors
                            $systemLogger = $this->getInitialContext()->getSystemLogger();
                            $systemLogger->error($ce->__toString());

                            // additionally log a message that CRON configuration will be missing
                            $systemLogger->critical(
                                sprintf('Will skip app specific CRON configuration %s, configuration might be faulty.', $cronFile)
                            );
                        }
                    }
                }
            }

        } catch (ConfigurationException $ce) {
            // load the logger and log the XML validation errors
            $systemLogger = $this->getInitialContext()->getSystemLogger();
            $systemLogger->error($ce->__toString());

            // additionally log a message that DS will be missing
            $systemLogger->critical(
                sprintf('Problems validating base CRON file %s, this might affect app configurations badly.', $baseCronPath)
            );
        }

        // return the array with the CRON instances
        return $cronInstances;
    }
991737
public static function get_request_statuses() {
        return [
            api::DATAREQUEST_STATUS_PENDING => get_string('statuspending', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_AWAITING_APPROVAL => get_string('statusawaitingapproval', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_APPROVED => get_string('statusapproved', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_PROCESSING => get_string('statusprocessing', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_COMPLETE => get_string('statuscomplete', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_DOWNLOAD_READY => get_string('statusready', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_EXPIRED => get_string('statusexpired', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_CANCELLED => get_string('statuscancelled', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_REJECTED => get_string('statusrejected', 'tool_dataprivacy'),
            api::DATAREQUEST_STATUS_DELETED => get_string('statusdeleted', 'tool_dataprivacy'),
        ];
    }