PHP 8.2.31
Preview: Supervisor.php Size: 1.36 KB
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Cron/Supervisor.php

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\Cron;

if (!defined('ABSPATH')) exit;


class Supervisor {
  public $daemon;
  public $token;

  /** @var CronHelper */
  private $cronHelper;

  public function __construct(
    CronHelper $cronHelper
  ) {
    $this->cronHelper = $cronHelper;
  }

  public function init() {
    $this->token = $this->cronHelper->createToken();
    $this->daemon = $this->getDaemon();
  }

  public function checkDaemon() {
    $daemon = $this->daemon;
    $updatedAt = $daemon ? (int)$daemon['updated_at'] : 0;
    $executionTimeoutExceeded =
      (time() - $updatedAt) >= $this->cronHelper->getDaemonExecutionTimeout();
    $daemonIsInactive =
      isset($daemon['status']) && $daemon['status'] === CronHelper::DAEMON_STATUS_INACTIVE;
    if ($executionTimeoutExceeded || $daemonIsInactive) {
      $this->cronHelper->restartDaemon($this->token);
      return $this->runDaemon();
    }
    return $daemon;
  }

  public function runDaemon() {
    $this->cronHelper->accessDaemon($this->token);
    $daemon = $this->cronHelper->getDaemon();
    return $daemon;
  }

  public function getDaemon() {
    $daemon = $this->cronHelper->getDaemon();
    if (!$daemon) {
      $this->cronHelper->createDaemon($this->token);
      return $this->runDaemon();
    }
    return $daemon;
  }
}

Directory Contents

Dirs: 3 × Files: 10

Name Size Perms Modified Actions
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
Triggers DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
Workers DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
7.13 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.71 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
939 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
6.00 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.99 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.62 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.04 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
5.13 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.36 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).