Add composer.json for Workerman and load vendor autoload in websocket server
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "saqel/backend",
|
||||||
|
"description": "Saqel Platform Backend Architecture with Workerman WebSocket Engine",
|
||||||
|
"type": "project",
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.2",
|
||||||
|
"workerman/workerman": "^4.1"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,12 @@
|
|||||||
* - 4041 : Internal HTTP Event Dispatcher for PHP Backend
|
* - 4041 : Internal HTTP Event Dispatcher for PHP Backend
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
} elseif (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||||
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
}
|
||||||
|
|
||||||
use Workerman\Worker;
|
use Workerman\Worker;
|
||||||
use Workerman\Connection\TcpConnection;
|
use Workerman\Connection\TcpConnection;
|
||||||
|
|
||||||
@@ -15,8 +21,8 @@ require_once __DIR__ . '/../app/Core/Security.php';
|
|||||||
require_once __DIR__ . '/../app/Core/Database.php';
|
require_once __DIR__ . '/../app/Core/Database.php';
|
||||||
|
|
||||||
// 1. Initialize Public WebSocket Server
|
// 1. Initialize Public WebSocket Server
|
||||||
$wsPort = (int)(getenv('WS_PORT') ?: 4040);
|
$wsPort = (int)(getenv('WS_PORT') ?: 4240);
|
||||||
$internalPort = (int)(getenv('WS_INTERNAL_PORT') ?: 4041);
|
$internalPort = (int)(getenv('WS_INTERNAL_PORT') ?: 4241);
|
||||||
|
|
||||||
$wsWorker = new Worker("websocket://0.0.0.0:{$wsPort}");
|
$wsWorker = new Worker("websocket://0.0.0.0:{$wsPort}");
|
||||||
$wsWorker->count = 1; // Single process for unified in-memory connection registry
|
$wsWorker->count = 1; // Single process for unified in-memory connection registry
|
||||||
|
|||||||
Reference in New Issue
Block a user