-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathworker.php
More file actions
37 lines (28 loc) · 913 Bytes
/
worker.php
File metadata and controls
37 lines (28 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Aternos\Mclogs\Api\ApiRouter;
use Aternos\Mclogs\Config\Config;
use Aternos\Mclogs\Config\ConfigKey;
use Aternos\Mclogs\Frontend\FrontendRouter;
use Aternos\Mclogs\Storage\MongoDBClient;
use Aternos\Mclogs\Util\URL;
require_once __DIR__ . '/vendor/autoload.php';
try {
MongoDBClient::getInstance()->ensureIndexes();
} catch (Exception $e) {
error_log("Failed to ensure MongoDB indexes: " . $e->getMessage());
}
$requestCount = 0;
$maxRequests = Config::getInstance()->get(ConfigKey::WORKER_REQUESTS);
do {
$running = \frankenphp_handle_request(function () {
MongoDBClient::getInstance()->reset();
URL::clear();
if (URL::isApi()) {
ApiRouter::getInstance()->run();
} else {
FrontendRouter::getInstance()->run();
}
});
gc_collect_cycles();
$requestCount++;
} while ($running && $requestCount < $maxRequests);