搭了个 Laravel Pulse 在线 demo,欢迎体验
在线体验 Pulse 面板: pulse-demo.xuchunyang.cn/pulse
下午试了试 Laravel Pulse 面板,顺便用 Forge 部署到了线上,为了能有东西监控,针对性地加了:
- eloquent 数据库 (「用户管理」、「电影列表」)
- 队列 (「测试 Queue 任务」)
- 缓存 (「用户登录」)
- 服务器端发起 http 请求 (「抓取网站 SEO」)
监听 Event 事件
Pulse 面板主要通过监听各种 Event 事件,获得各种数据。安装 Pulse 后,会发现增加了很多监听:
➜ pulse-demo git:(main) artisan event:list | grep -i -B 1 pulse
Illuminate\Auth\Events\Logout .......................................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:120
--
Illuminate\Cache\Events\CacheHit ....................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Cache\Events\CacheMissed .................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Database\Events\QueryExecuted ............................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Queue\Events\JobFailed ...................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Queue\Events\JobProcessed ................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Queue\Events\JobProcessing ...............................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Queue\Events\JobQueued ...................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
--
Illuminate\Queue\Events\JobReleasedAfterException ...................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
Illuminate\Queue\Events\Looping .....................................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:129
Illuminate\Queue\Events\WorkerStopping ..............................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:129
Laravel\Octane\Events\RequestReceived ...............................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:152
--
Laravel\Octane\Events\TaskReceived ..................................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:152
Laravel\Octane\Events\TickReceived ..................................
⇂ Closure at: /vendor/laravel/pulse/src/PulseServiceProvider.php:152
Laravel\Pulse\Events\ExceptionReported ..............................
⇂ Closure at: /vendor/laravel/pulse/src/Recorders/Exceptions.php:40
Laravel\Pulse\Events\SharedBeat .....................................
⇂ Closure at: /vendor/laravel/pulse/src/Pulse.php:123
➜ pulse-demo git:(main)
默认的采样率相当于是 100%,比如所有的 CacheHit 事件都会被一一记录,对于某些应用估计会影响性能,但我还没了解过自定义采样率。
服务器状态其实跟 Laravel 没多少关系,它也是单独实现的,在 Forge 上会让你开启一个 pulse:check 的后台 daemon,定期更新服务器信息。
推荐文章: