SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
43 stars 8 forks source link

Too many workers #68

Closed da-mask closed 5 months ago

da-mask commented 5 months ago

I am working on a remote development server using VSCode's Remote-SSH. This extension consumes the server's memory fairly rapidly, when I look at services running I seem 10s of '/etc/php/8.2/cli/php.ini' '/vendor/bin/phpstan' 'worker' --configuration '/var/wwww/folder/phpstan.neon' --memory-limit='800M' --port 43171 --identifier iwnhtr3wd7 --, they keep multiplying until the server becomes unusable. The processes continue even after the connection is closed. New port numbers are generated for new workers.

Is there a way to limit the number of workers the extension can create?

Extension version: both stable and pre-release (currently have 3.0.6 installed).

SanderRonde commented 5 months ago

Hi, what the extension does is that it basically just runs phpstan with your own config file and interprets the output. You might want to check out this section of the PHPStan docs, you can use that to limit the number of processes. You'll notice that if you run PHPStan by itself it'll do the exact same thing. Those processes you mention are PHPStan worker processes.

The processes indeed don't stop if the connection is closed, this is a bit of a limitation of VSCode where an extension doesn't get a "killed" event, with which I'd be able to kill the process. It also doesn't spawn the process under the VSCode process itself, meaning that if the VSCode server is killed, the process doesn't go down with it. Theoretically any open processes are killed when the extension starts again after disconnecting, since that's the first time it has control again.

Hope this helps, let me know if it doesn't

da-mask commented 5 months ago

I guess I've proven myself to be one of those guys that don't read the docs. Thank you for very kindly pointing out where in it tells me how to fix my issue, I'm pretty sure you are right and setting the max processes should keep things under control for me.

And thanks for creating and maintaining a really good extension. 🔥

SanderRonde commented 5 months ago

Haha no problem, and thanks for the kind words!