mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
fix workerman select exit fake fatal bug
This commit is contained in:
@@ -7,6 +7,7 @@ namespace ZM\Event\Listener;
|
||||
use OneBot\Driver\Coroutine\Adaptive;
|
||||
use OneBot\Driver\Coroutine\CoroutineInterface;
|
||||
use OneBot\Driver\Process\ProcessManager;
|
||||
use OneBot\Driver\Workerman\Worker;
|
||||
use OneBot\Util\Singleton;
|
||||
use ZM\Annotation\AnnotationHandler;
|
||||
use ZM\Annotation\AnnotationMap;
|
||||
@@ -85,9 +86,9 @@ class WorkerEventListener
|
||||
register_shutdown_function(function () {
|
||||
$error = error_get_last();
|
||||
// 下面这段代码的作用就是,不是错误引发的退出时照常退出即可
|
||||
if (($error['type'] ?? 0) != 0) {
|
||||
if (($error['type'] ?? 0) === 1) {
|
||||
logger()->emergency(zm_internal_errcode('E00027') . 'Internal fatal error: ' . $error['message'] . ' at ' . $error['file'] . "({$error['line']})");
|
||||
} elseif (!isset($error['type'])) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Framework::getInstance()->stop();
|
||||
@@ -119,6 +120,9 @@ class WorkerEventListener
|
||||
|
||||
public function onWorkerStart1(): void
|
||||
{
|
||||
if (Framework::getInstance()->getDriver()->getName() === 'workerman') {
|
||||
logger()->debug('Workerman 使用了事件循环:' . Worker::$eventLoopClass);
|
||||
}
|
||||
logger()->debug('{is_task}Worker 进程 #{id} 已启动', ['is_task' => ProcessStateManager::isTaskWorker() ? 'Task' : '', 'id' => ProcessManager::getProcessId()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,11 @@ class PluginGenerator
|
||||
file_put_contents(zm_dir($plugin_base_dir . '/composer.json'), json_encode($composer_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
// TODO: 寻找 PHP 运行环境和 Composer 是否在当前目录的情况
|
||||
chdir($plugin_base_dir);
|
||||
passthru('composer dump-autoload');
|
||||
$env = getenv('COMPOSER_EXECUTABLE');
|
||||
if ($env === false) {
|
||||
$env = 'composer';
|
||||
}
|
||||
passthru(PHP_BINARY . ' ' . escapeshellcmd($env) . ' dump-autoload');
|
||||
chdir(WORKING_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user