Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix serve command with PHP_CLI_SERVER_WORKERS #54606

Merged
merged 10 commits into from
Feb 17, 2025
Merged

Conversation

crynobone
Copy link
Member

By default, serve command would restart child process when there's modification to the .env file. However, with PHP_CLI_SERVER_WORKERS set to larger than 1 the process doesn't close properly (port is still being used) and this cause the restart process to pick an incremented port number.

The changes here will unset PHP_CLI_SERVER_WORKERS value unless the command is executed with --no-reload option.

fixes #54574

crynobone and others added 6 commits February 14, 2025 10:04
By default, serve command would restart child process when there's
modification to the `.env` file. However, with `PHP_CLI_SERVER_WORKERS`
set to larger than 1 the process doesn't close properly (port is still
being used) and this cause the restart process to pick an incremented
port number.

The changes here will unset `PHP_CLI_SERVER_WORKERS` value unless the
command is executed with `--no-reload` option.

fixes #54574

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@crynobone crynobone changed the title Fixes serve command with PHP_CLI_SERVER_WORKERS [11.x] Fix serve command with PHP_CLI_SERVER_WORKERS Feb 14, 2025
@crynobone crynobone marked this pull request as ready for review February 15, 2025 02:06
@taylorotwell taylorotwell merged commit f03d3a1 into 11.x Feb 17, 2025
7 of 9 checks passed
@taylorotwell taylorotwell deleted the fixes-54574 branch February 17, 2025 17:06
@BrainStone
Copy link

Hey there. Apologies for necroing this PR/thread.

However I do have a few questions regarding the changes made here. If this isn't the appropriate place to ask, I'm happy to ask where ever you recommend me to.

Now I am wondering why it has been chosen to silently ignore a configuration value under fairly intransparent conditions (I mean the code is clear, but to people not knowing this code, the conditions are very unclear) instead of addressing the underlying issue at hand.
Is this an issue with the PHP development server? I've come across many comments and blurps that say something along the lines that the experimental support for PHP_CLI_SERVER_WORKERS in the built-in PHP development server either are or could be causing this issue where reloading doesn't free up the port, so the next instance gets a different port.

Additionally is there documentation for this behavior? I'm not saying there isn't any, just that I haven't come across any mention during my multi hour deep dive into why an update of Laravel suddenly caused timeouts in my dev server (which eventually lead me down the path of debugging why PHP_CLI_SERVER_WORKERS was getting ignored).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Env modification increments server port
4 participants