-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
33 lines (24 loc) · 974 Bytes
/
server.php
File metadata and controls
33 lines (24 loc) · 974 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
<?php
declare(strict_types=1);
use App\Helpers\DotEnv;
use App\Helpers\RouteRegistry;
use App\Helpers\Server;
// Load Dependencies
require __DIR__ . '/vendor/autoload.php';
// require __DIR__ . '/multiprocess.php';
// TODOv2 : Fork main process to scale into workers and get rid of framework-x
// $workerNumber = get_cpu_count();
// echo 'Starting ' . $workerNumber . ' servers on machine...\r\n';
// Load Env
DotEnv::loadEnv();
// Init new Application
$server = Server::getInstance();
// Route Config
$router = RouteRegistry::getInstance($server);
$router->register(require __DIR__ . '/src/Routes.php');
// Preload Connection Pools & Services at app startup to avoid cold starts
require __DIR__ . '/src/Preload.php';
// Run App
$socket = new React\Socket\SocketServer(DotEnv::env('APP_HOST', '127.0.0.1') . ":" . DotEnv::env('APP_PORT', '8080'));
$server->listen($socket);
echo 'Server running at ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;