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
--hostin the commandline, it wouldn't work and always stick to127.0.0.1.Additionally,
bin/createSwooleServer.phpcontains a default port value of8080despite 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.phpis using a default value of127.0.0.1for--hostwhen this argument is not provided in the command. But becausesrc/Commands/Concerns/InteractsWithServers.php'sgetHostlooks at this option first, it will always use the value127.0.0.1when you want to configure it using any method except the command line.The fix
In
src/Commands/StartCommand.php&src/Commands/StartSwooleCommand.phpI removed the default value of127.0.0.1for--hostas that's already handled bysrc/Commands/Concerns/InteractsWithServers.phpin thegetHost()method.getHostmethod 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.phpConcern using the correct value of8000tocreateSwooleServer. Therefor the modification of8080to8000increateSwooleServershould have no effect on existing deployments (ie: there should be no way for thecreateSwooleServerportvariable to ever be empty and having to resort to the default).