Skip to content

[Bug] check_port in util.sh fails when restserver.url has no scheme prefix #3004

Description

@bitflicker64

Bug Type (问题类型)

other exception / error (其他异常报错)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: latest master
  • Backend: any
  • OS: CentOS 7.8 (reported), affects any OS with lsof

Expected & Actual behavior (期望与实际表现)

Starting hugegraph-server produces the following error:

lsof: unacceptable port specification in: -i :
Starting HugeGraphServer in daemon mode...

Root cause:
check_port() in util.sh extracts the port using:

local port=$(echo "$1" | awk -F':' '{print $3}')

This assumes a 3-part URL like http://host:port. Since #2944
removed the http:// prefix from the default config, restserver.url
now defaults to 127.0.0.1:8080 (no scheme). Splitting on : gives
only 2 fields, so $3 is empty and lsof -i : is called with no port.

Note: check_port accidentally works for gremlin because its fallback
hardcodes http://127.0.0.1:8182 — only the REST URL is broken.

The same broken check_port exists in all three util.sh files:

  • hugegraph-server/.../bin/util.sh line 84
  • hugegraph-pd/.../bin/util.sh line 86
  • hugegraph-store/.../bin/util.sh line 85

Though only hugegraph-server actively calls it.

Fix: replace the awk expression with:

local port=$(echo "$1" | sed 's|.:||' | sed 's|/.||')

This correctly handles all URL formats:

Related: #2944 (changed default restserver.url format, exposing this bug)
Reported in: #3001

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions