Removed onStart event from server default callbacks when the mode is SWOOLE_BASE. (#2963)

* Optimized Server defaultCallbacks

* Format code.

* Update CHANGELOG-2.0.md

Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
motian 2020-12-12 19:45:44 +08:00 committed by GitHub
parent 28fa61c687
commit 481b3bd6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -17,6 +17,7 @@
- [#2951](https://github.com/hyperf/hyperf/pull/2951) Optimized code for model-cache, which will delete model cache only once, when using it in transaction.
- [#2953](https://github.com/hyperf/hyperf/pull/2953) Hide `Swoole\ExitException` trace message in command.
- [#2963](https://github.com/hyperf/hyperf/pull/2963) Removed `onStart` event from server default callbacks when the mode is `SWOOLE_BASE`.
# v2.0.22 - 2020-12-07

View File

@ -209,18 +209,24 @@ class Server implements ServerInterface
protected function defaultCallbacks()
{
$hasCallback = class_exists(Bootstrap\StartCallback::class) &&
class_exists(Bootstrap\ManagerStartCallback::class) &&
class_exists(Bootstrap\WorkerStartCallback::class);
$hasCallback = class_exists(Bootstrap\StartCallback::class)
&& class_exists(Bootstrap\ManagerStartCallback::class)
&& class_exists(Bootstrap\WorkerStartCallback::class);
if ($hasCallback) {
return [
SwooleEvent::ON_START => [Bootstrap\StartCallback::class, 'onStart'],
$callbacks = [
SwooleEvent::ON_MANAGER_START => [Bootstrap\ManagerStartCallback::class, 'onManagerStart'],
SwooleEvent::ON_WORKER_START => [Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
SwooleEvent::ON_WORKER_STOP => [Bootstrap\WorkerStopCallback::class, 'onWorkerStop'],
SwooleEvent::ON_WORKER_EXIT => [Bootstrap\WorkerExitCallback::class, 'onWorkerExit'],
];
if ($this->server->mode === SWOOLE_BASE) {
return $callbacks;
}
return array_merge([
SwooleEvent::ON_START => [Bootstrap\StartCallback::class, 'onStart'],
], $callbacks);
}
return [