add auto-reconnect method to terminal_listener.php

add short name of ZM_BREAKPOINT (BP)
fix loop error of syntax happened
This commit is contained in:
whale
2020-06-20 14:51:24 +08:00
parent dc7af105f4
commit e976a96d0b
7 changed files with 21 additions and 10 deletions

View File

@@ -184,6 +184,7 @@ class Console
$vss->callback = function(?WSConnection $conn) use ($terminal_id){
$req = ctx()->getRequest();
if($conn->getType() != "terminal") return false;
Console::debug("Terminal fd: ".$conn->fd);
if(($req->header["x-terminal-id"] ?? "") != $terminal_id) {
$conn->close();
return false;
@@ -195,6 +196,7 @@ class Console
$vss2->type = "message";
$vss2->rule = "connectType:terminal";
$vss2->callback = function(?WSConnection $conn){
if ($conn === null) return false;
if($conn->getType() != "terminal") return false;
$cmd = ctx()->getFrame()->data;
self::executeCommand($cmd);

View File

@@ -151,6 +151,7 @@ class FrameworkLoader
define("ZM_MATCH_NUMBER", 2);
define("ZM_MATCH_SECOND", 3);
define("ZM_BREAKPOINT", 'if(in_array("--debug-mode", \Framework\FrameworkLoader::$argv)) extract(\Psy\debug(get_defined_vars(), isset($this) ? $this : @get_called_class()));');
define("BP", ZM_BREAKPOINT);
define("ZM_DEFAULT_FETCH_MODE", self::$settings->get("sql_config")["sql_default_fetch_mode"] ?? 4);
}

View File

@@ -3,6 +3,7 @@
use Swoole\Coroutine\Http\Client;
Co\run(function (){
hello:
global $terminal_id, $port;
$client = new Client("127.0.0.1", $port);
$client->set(['websocket_mask' => true]);
@@ -17,8 +18,9 @@ Co\run(function (){
break;
}
if($r === false) {
echo "Unable to connect framework terminal, connection closed.\n";
break;
echo "Unable to connect framework terminal, connection closed. Trying to reconnect after 5s.\n";
sleep(5);
goto hello;
}
} else {
break;