diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..5bad95e0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +# Exclude build/test files from archive (reduce package size) +/.github export-ignore +/.phive export-ignore +/build export-ignore +/docs export-ignore +/ext export-ignore +/resources export-ignore +/tests export-ignore +/tests_old export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.php export-ignore +/captainhook.json export-ignore +/install-runtime.sh export-ignore +/package.json export-ignore +/phpstan.neon export-ignore +/phpunit.xml.dist export-ignore + +# Configure diff output +*.php diff=php diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index 09017f82..9847a787 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -24,6 +24,7 @@ jobs: if: ${{ needs.pre_job.outputs.should_skip != 'true' }} name: Code Style runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1a61be59..0b813362 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -24,6 +24,7 @@ jobs: if: ${{ needs.pre_job.outputs.should_skip != 'true' }} name: Static Analysis runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a636b444..ed09c156 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,7 @@ jobs: php-version: [ 8.0, 8.1, 8.2 ] name: PHP ${{ matrix.php-version }} Test (${{ matrix.operating-system }}) runs-on: ${{ matrix.operating-system }} + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/bin/prepare-doxygen b/bin/prepare-doxygen old mode 100644 new mode 100755 diff --git a/src/ZM/Event/Listener/WorkerEventListener.php b/src/ZM/Event/Listener/WorkerEventListener.php index 540ed1b7..70b5b664 100644 --- a/src/ZM/Event/Listener/WorkerEventListener.php +++ b/src/ZM/Event/Listener/WorkerEventListener.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace ZM\Event\Listener; use OneBot\Driver\Coroutine\Adaptive; +use OneBot\Driver\Coroutine\CoroutineInterface; use OneBot\Driver\Process\ProcessManager; use OneBot\Util\Singleton; use ZM\Annotation\AnnotationHandler; @@ -96,9 +97,13 @@ class WorkerEventListener $this->initUserPlugins(); // handle @Init annotation - Adaptive::getCoroutine()->create(function () { + if (Adaptive::getCoroutine() instanceof CoroutineInterface) { + Adaptive::getCoroutine()->create(function () { + $this->dispatchInit(); + }); + } else { $this->dispatchInit(); - }); + } // 回显 debug 日志:进程占用的内存 $memory_total = memory_get_usage() / 1024 / 1024; logger()->debug('Worker process used ' . round($memory_total, 3) . ' MB');