walkor / workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
http://www.workerman.net
MIT License
11.03k stars 2.25k forks source link

Temp files processing refactoring #982

Closed luzrain closed 8 months ago

luzrain commented 8 months ago

I propose some changes in the way we work with temporary files during the execution of the "status" and "connections" commands.

Changes:

Breaking changes:

Breaking changes in protected scope:

May only affect those who have overridden the Workerman class.

Other changes: Pid file default path also uses system temp directory by default. Sleep time during "status" command execution reduced to 0.5sec.

luzrain commented 8 months ago

One more thing I want to discuss. Do we even need the ability to set custom paths for status files since they are stored in the system temp directory by default? Maybe it's worth to removing $processStatusFile and $connectionStatusFile from the public scope at all? What do you think?

luzrain commented 8 months ago

I've found the reason why the original temp directories were changed, so it might be better to save temp files in the old place. It's up to you. https://github.com/walkor/workerman/issues/629 Personally, I think it is a bad idea to save any temp files in the vendor directory.

walkor commented 8 months ago

Thank you very much for your PR. I suggest keeping the statusFile so that old projects can be directly upgraded without making any changes. The default value of pidFile is sys_get_temp_dir(), in Linux systems it is likely to be the /tmp directory, and many operating systems regularly clean up the /tmp directory, resulting in the loss of pid files.

luzrain commented 8 months ago

I returned public $statusFile and changed back default system temp paths šŸ‘Œ