laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.73k stars 288 forks source link

Octane does not call close() on Monolog Handler #850

Closed NiroDeveloper closed 4 months ago

NiroDeveloper commented 4 months ago

Octane Version

2.3.4

Laravel Version

10.46.0

PHP Version

8.1.27

What server type are you using?

Swoole

Server Version

5.1.2

Database Driver & Version

No response

Description

Laravel uses Monolog for logging, some monolog handler have a important close() function. Octane does never call this function! In normal laravel applications, monolog calls close by itself via __destruct(). It seams like __destruct() is never called in Swoole and it could be sensible to call close() after every request.

Taking into account that there is currently only one workaround to write performant logs: https://github.com/laravel/octane/issues/724#issuecomment-1649617729 In this case the ProcessHandler::close() is never called and laravel will spawn endless cat processes.

Steps To Reproduce

  1. Create an endpoint that writes information to the Log facade
  2. Create a log driver that requires an close() call, like in https://github.com/laravel/octane/issues/724#issuecomment-1649617729
  3. Run linux ps and see that for every request a cat process was created but not closed.
NiroDeveloper commented 4 months ago

@driesvints This is a different problem then https://github.com/laravel/octane/issues/724, this could also generate problems while using other monolog handlers like StreamHandler, SocketHandler or SyslogHandler.

github-actions[bot] commented 4 months ago

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!