2026-03-15 10:20:42 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
2026-03-26 03:33:01 +08:00
|
|
|
use App\WebSocket\NodeWorker;
|
2026-03-15 10:20:42 +08:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class NodeWebSocketServer extends Command
|
|
|
|
|
{
|
2026-03-15 10:57:21 +08:00
|
|
|
protected $signature = 'ws-server
|
2026-03-15 10:20:42 +08:00
|
|
|
{action=start : start | stop | restart | reload | status}
|
|
|
|
|
{--d : Start in daemon mode}
|
|
|
|
|
{--host=0.0.0.0 : Listen address}
|
|
|
|
|
{--port=8076 : Listen port}';
|
|
|
|
|
|
|
|
|
|
protected $description = 'Start the WebSocket server for node-panel synchronization';
|
|
|
|
|
|
|
|
|
|
public function handle(): void
|
|
|
|
|
{
|
|
|
|
|
global $argv;
|
|
|
|
|
$action = $this->argument('action');
|
|
|
|
|
|
|
|
|
|
$argv[1] = $action;
|
|
|
|
|
if ($this->option('d')) {
|
|
|
|
|
$argv[2] = '-d';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$host = $this->option('host');
|
|
|
|
|
$port = $this->option('port');
|
|
|
|
|
|
2026-03-26 03:33:01 +08:00
|
|
|
$worker = new NodeWorker($host, $port);
|
|
|
|
|
$worker->run();
|
2026-03-15 10:20:42 +08:00
|
|
|
}
|
|
|
|
|
}
|