Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit b6aa8e7

Browse files
committed
🐛 修复断开主控连接时不会结束进程
1 parent 431dc28 commit b6aa8e7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

inc/socketio.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function connect() {
4747
}
4848
if ($code[0] == '41'){
4949
mlog("[socket.io]Close Connection");
50+
global $pid;
51+
posix_kill($pid, SIGINT);
5052
$client->close();
5153
return;
5254
}

main.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
const VERSION = '1.10.3';
99
global $DOWNLOAD_DIR;
1010
$DOWNLOAD_DIR = $config['cache_dir'];
11-
const USERAGENT = 'openbmclapi-cluster/' . VERSION . ' ' . 'PHP-OpenBmclApi/'.PHPOBAVERSION;
11+
const USERAGENT = 'openbmclapi-cluster/' . VERSION . ' ' . 'PHP-OpenBmclApi/'.PHPOBAVERSION;
1212
const OPENBMCLAPIURL = 'openbmclapi.bangbang93.com';
1313
global $tokendata;
1414
$list = glob('./inc/*.php');
1515
foreach ($list as $file) {
1616
$file = explode('/', $file)['2'];
1717
require './inc/' . $file;
1818
}
19+
global $pid;
20+
$pid = getmypid();
1921
echo"OpenBmclApionPHP v0.0.1-dev". PHP_EOL;
2022
run(function()use ($config){
2123
//注册信号处理器
@@ -28,7 +30,7 @@ function registerSigintHandler() {
2830
$shouldExit = true; // 设置退出标志
2931
Swoole\Timer::clear($timerId);
3032
echo PHP_EOL;
31-
mlog("主动退出...");
33+
mlog("正在退出...");
3234
exit();
3335
} catch (\Swoole\ExitException $e) {
3436
//var_dump($e->getMessage());
@@ -48,6 +50,7 @@ function registerSigintHandler() {
4850
$tokendata = $token->gettoken();
4951
mlog("GetNewToken:".$tokendata['token'],1);
5052
});
53+
global $socketio;
5154
registerSigintHandler();
5255
mlog("Timer start on ID{$timerId}",1);
5356

0 commit comments

Comments
 (0)