Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
Expand All @@ -26,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 8.0
php-version: 8.3
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
Expand All @@ -26,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: sunxyw/workflows/setup-environment@main
with:
php-version: 7.4
php-version: 8.3
php-extensions: swoole, posix, json
operating-system: ubuntu-latest
use-cache: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: same_content_newer
skip_after_successful_duplicate: true
Expand All @@ -34,12 +34,12 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-version: [ 7.4, 8.0, 8.1 ]
php-version: [ 8.1, 8.2, 8.3, 8.4 ]
name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"wiki": "https://github.com/botuniverse/php-libonebot/wiki"
},
"require": {
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
"php": "^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5",
"ext-json": "*",
"psr/cache": "^1.0 || ^3.0",
"psr/event-dispatcher": "^1.0",
Expand All @@ -38,11 +38,11 @@
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
"friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^1.1",
"phpunit/phpunit": "^9.0 || ^8.0",
"swoole/ide-helper": "~4.4.0",
"symfony/var-dumper": "^5.3"
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^9.0",
"swoole/ide-helper": "~5.0",
"symfony/var-dumper": "^5.3 || ^6.0 || ^7.0"
},
"suggest": {
"nunomaduro/collision": "Better display for exception and error message",
Expand Down
75 changes: 32 additions & 43 deletions src/OneBot/Driver/Workerman/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace OneBot\Driver\Workerman;

use Workerman\Connection\ConnectionInterface;
use Workerman\Events\EventInterface;
use Workerman\Lib\Timer;

/**
Expand Down Expand Up @@ -51,7 +52,7 @@ public static function runAll(): void
static::parseCommand(); // 解析命令行,但好像 libob 不太需要
static::daemonize(); // 创建守护进程,但 libob 好像也不太需要
static::initWorkers(); // 初始化 Worker 进程
// static::installSignal(); // 安装信号处理函数
static::installSignal(); // 安装信号处理函数
// static::saveMasterPid(); // 保存 Master PID
if (static::$_OS === OS_TYPE_LINUX) { // 此处替代上方的 saveMasterPid() 功能
static::$_masterPid = posix_getpid();
Expand Down Expand Up @@ -382,24 +383,23 @@ protected static function installSignal()
if (static::$_OS === OS_TYPE_WINDOWS) {
return;
}
echo "设置监听器\n";
$signalHandler = '\Workerman\Worker::signalHandler';
// // stop
// \pcntl_signal(\SIGINT, $signalHandler, false);
// // stop
// pcntl_signal(SIGTERM, $signalHandler, false);
// // graceful stop
// \pcntl_signal(\SIGHUP, $signalHandler, false);
// // reload
// stop (Ctrl+C)
\pcntl_signal(\SIGINT, $signalHandler, false);
// stop
\pcntl_signal(SIGTERM, $signalHandler, false);
// graceful stop (terminal closed / SIGHUP)
\pcntl_signal(\SIGHUP, $signalHandler, false);
// reload
\pcntl_signal(SIGUSR1, $signalHandler, false);
// // graceful reload
// \pcntl_signal(\SIGQUIT, $signalHandler, false);
// // status
// \pcntl_signal(\SIGUSR2, $signalHandler, false);
// // connection status
// \pcntl_signal(\SIGIO, $signalHandler, false);
// // ignore
// \pcntl_signal(\SIGPIPE, \SIG_IGN, false);
// graceful reload
\pcntl_signal(\SIGQUIT, $signalHandler, false);
// status
\pcntl_signal(\SIGUSR2, $signalHandler, false);
// connection status
\pcntl_signal(\SIGIO, $signalHandler, false);
// ignore SIGPIPE (prevent crash on broken pipe)
\pcntl_signal(\SIGPIPE, \SIG_IGN, false);
}

/**
Expand All @@ -413,32 +413,21 @@ protected static function reinstallSignal()
return;
}
$signalHandler = '\Workerman\Worker::signalHandler';
// // uninstall stop signal handler
// \pcntl_signal(\SIGINT, \SIG_IGN, false);
// // uninstall stop signal handler
// pcntl_signal(SIGTERM, SIG_IGN, false);
// // uninstall graceful stop signal handler
// \pcntl_signal(\SIGHUP, \SIG_IGN, false);
// // uninstall reload signal handler
// pcntl_signal(SIGUSR1, SIG_IGN, false);
// // uninstall graceful reload signal handler
// \pcntl_signal(\SIGQUIT, \SIG_IGN, false);
// // uninstall status signal handler
// \pcntl_signal(\SIGUSR2, \SIG_IGN, false);
// // uninstall connections status signal handler
// \pcntl_signal(\SIGIO, \SIG_IGN, false);
// // reinstall stop signal handler
// static::$globalEvent->add(\SIGINT, EventInterface::EV_SIGNAL, $signalHandler);
// // reinstall graceful stop signal handler
// static::$globalEvent->add(\SIGHUP, EventInterface::EV_SIGNAL, $signalHandler);
// // reinstall reload signal handler
// static::$globalEvent->add(SIGUSR1, EventInterface::EV_SIGNAL, $signalHandler);
// // reinstall graceful reload signal handler
// static::$globalEvent->add(\SIGQUIT, EventInterface::EV_SIGNAL, $signalHandler);
// // reinstall status signal handler
// static::$globalEvent->add(\SIGUSR2, EventInterface::EV_SIGNAL, $signalHandler);
// // reinstall connection status signal handler
// static::$globalEvent->add(\SIGIO, EventInterface::EV_SIGNAL, $signalHandler);
// uninstall old pcntl handlers first
\pcntl_signal(\SIGINT, \SIG_IGN, false);
\pcntl_signal(SIGTERM, \SIG_IGN, false);
\pcntl_signal(\SIGHUP, \SIG_IGN, false);
\pcntl_signal(SIGUSR1, \SIG_IGN, false);
\pcntl_signal(\SIGQUIT, \SIG_IGN, false);
\pcntl_signal(\SIGUSR2, \SIG_IGN, false);
\pcntl_signal(\SIGIO, \SIG_IGN, false);
// reinstall via event loop (supports all available event backends: Select, Event, Ev, etc.)
static::$globalEvent->add(\SIGINT, EventInterface::EV_SIGNAL, $signalHandler);
static::$globalEvent->add(\SIGHUP, EventInterface::EV_SIGNAL, $signalHandler);
static::$globalEvent->add(SIGUSR1, EventInterface::EV_SIGNAL, $signalHandler);
static::$globalEvent->add(\SIGQUIT, EventInterface::EV_SIGNAL, $signalHandler);
static::$globalEvent->add(\SIGUSR2, EventInterface::EV_SIGNAL, $signalHandler);
static::$globalEvent->add(\SIGIO, EventInterface::EV_SIGNAL, $signalHandler);
}

/**
Expand Down
Loading