mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 06:14:55 +00:00
11b2066922
Includes PHPDoc license tag in the file-level block with accompanying copyright notice. Also added an AUTHORS file on the off chance of outside contributions
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
/** @license MIT
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\Arsse\Service\Forking;
|
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
class Driver implements \JKingWeb\Arsse\Service\Driver {
|
|
protected $queue = [];
|
|
|
|
public static function driverName(): string {
|
|
return Arsse::$lang->msg("Driver.Service.Forking.Name");
|
|
}
|
|
|
|
public static function requirementsMet(): bool {
|
|
return function_exists("popen");
|
|
}
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public function queue(int ...$feeds): int {
|
|
$this->queue = array_merge($this->queue, $feeds);
|
|
return sizeof($this->queue);
|
|
}
|
|
|
|
public function exec(): int {
|
|
$pp = [];
|
|
while ($this->queue) {
|
|
$id = (int) array_shift($this->queue);
|
|
$php = '"'.\PHP_BINARY.'"';
|
|
$arsse = '"'.$_SERVER['argv'][0].'"';
|
|
array_push($pp, popen("$php $arsse feed refresh $id", "r"));
|
|
}
|
|
while ($pp) {
|
|
$p = array_pop($pp);
|
|
fgets($p); // TODO: log output
|
|
pclose($p);
|
|
}
|
|
return Arsse::$conf->serviceQueueWidth - sizeof($this->queue);
|
|
}
|
|
|
|
public function clean(): bool {
|
|
$this->queue = [];
|
|
return true;
|
|
}
|
|
}
|