bitflicker64 commented on issue #3001:
URL: https://github.com/apache/hugegraph/issues/3001#issuecomment-4301651499

   @mywgl Thanks for tracking this down. You're right about the root cause — 
`check_port` uses `awk -F':' '{print $3}'` which assumes a 3-part URL like 
`http://host:port`, but `restserver.url` defaults to `127.0.0.1:8080` with no 
scheme, so field 3 is empty and `lsof -i :` gets called with no port argument.
   
   Your `$NF` fix works for the common case but has one edge case — if the URL 
has a path or trailing slash like `http://127.0.0.1:8080/graphs`, `$NF` returns 
`8080/graphs` which would also fail. A more robust fix:
   
   ```bash
   local port=$(echo "$1" | sed 's|.*:||' | sed 's|/.*||')
   ```
   
   This handles all formats correctly — `host:port`, `http://host:port`, 
`http://host:port/path`, and even IPv6.
   
   Note this bug only actively affects `hugegraph-server` — the same broken 
`check_port` exists in `hugegraph-pd` and `hugegraph-store` util.sh files but 
is never called from their start scripts. All three should be fixed for 
consistency though.
   
   Will open a separate issue and PR for this.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to