Fix swoole host only configurable via --host parameter + incorrect default port #762
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
When attempting to configure Swoole to bind on a different host using anything except
--host
in the commandline, it wouldn't work and always stick to127.0.0.1
.Additionally,
bin/createSwooleServer.php
contains a default port value of8080
despite the command stating the default is8000
.The issue
octane.host
, the$serverState['host']
will stay at127.0.0.1
, and only$serverState['octaneConfig']['host']
changes to the configured value.The cause
src/Commands/StartCommand.php
is using a default value of127.0.0.1
for--host
when this argument is not provided in the command. But becausesrc/Commands/Concerns/InteractsWithServers.php
'sgetHost
looks at this option first, it will always use the value127.0.0.1
when you want to configure it using any method except the command line.The fix
In
src/Commands/StartCommand.php
&src/Commands/StartSwooleCommand.php
I removed the default value of127.0.0.1
for--host
as that's already handled bysrc/Commands/Concerns/InteractsWithServers.php
in thegetHost()
method.getHost
method is also used with Roadrunner, so I did the same modification forsrc/Commands/StartRoadRunnerCommand.php
.The current default port value is provided via the
InteractsWithServers.php
Concern using the correct value of8000
tocreateSwooleServer
. Therefor the modification of8080
to8000
increateSwooleServer
should have no effect on existing deployments (ie: there should be no way for thecreateSwooleServer
port
variable to ever be empty and having to resort to the default).