count = (int) shell_exec('nproc') ?? 64; $http_worker->onWorkerStart = function () { global $pdo; $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world;charset=utf8', 'benchmarkdbuser', 'benchmarkdbpass'); }; $http_worker->onMessage = static function ($connection) { global $pdo; Http::header('Date: '.gmdate('D, d M Y H:i:s').' GMT'); switch (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) { case '/plaintext': Http::header('Content-Type: text/plain'); return $connection->send('Hello, World!'); case '/json': Http::header('Content-Type: application/json'); return $connection->send(json_encode(['message' => 'Hello, World!'])); case '/db': Http::header('Content-Type: application/json'); return $connection->send(dbraw($pdo)); case '/fortune': Http::header('Content-Type: text/html; charset=utf-8'); return $connection->send(fortune($pdo)); case '/update': Http::header('Content-Type: application/json'); return $connection->send(updateraw($pdo)); //case '/info': // Http::header('Content-Type: text/plain'); // ob_start(); // phpinfo(); // $connection->send(ob_get_clean()); //default: // $connection->send('error'); } }; Worker::runAll();