Skip to content

Commit 1e40b61

Browse files
authored
The submission of two gql files simultaneously using gql_submit failed due to a port conflict related to the dashboard. (#491)
1 parent 291d07c commit 1e40b61

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

bin/gql_submit.sh

+45-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,49 @@ while [ "$1" ]; do
6464
shift
6565
done
6666

67-
DEFAULT_JOB_ARGS='{"job": {"geaflow.log.dir": "/tmp/geaflow/logs", "geaflow.agent.http.port": "8088", "AGENT_PROFILER_PATH": "'${ASYNC_PROFILER_SHELL_PATH}'"}}'
67+
agent_port=8088
68+
master_port=8090
69+
70+
if ! command -v lsof &> /dev/null; then
71+
echo "lsof is not installed. Using default port numbers."
72+
else
73+
check_port() {
74+
local port=$1
75+
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
76+
return 0 # 端口被占用
77+
else
78+
return 1 # 端口未被占用
79+
fi
80+
}
81+
82+
find_available_port() {
83+
local start_port=$1
84+
while check_port $start_port; do
85+
((start_port++))
86+
done
87+
echo $start_port
88+
}
89+
90+
while check_port $agent_port; do
91+
agent_port=$(find_available_port $agent_port)
92+
done
93+
master_port=$((agent_port + 1))
94+
while check_port $master_port; do
95+
master_port=$(find_available_port $master_port)
96+
done
97+
fi
98+
99+
DEFAULT_JOB_ARGS=$(cat <<EOF
100+
{
101+
"job": {
102+
"geaflow.log.dir": "/tmp/geaflow/logs",
103+
"geaflow.agent.http.port": "${agent_port}",
104+
"geaflow.master.http.port": "${master_port}",
105+
"AGENT_PROFILER_PATH": "${ASYNC_PROFILER_SHELL_PATH}"
106+
}
107+
}
108+
EOF
109+
)
68110
JOB_ARGS=${JOB_ARGS:-${DEFAULT_JOB_ARGS}}
69111
echo "JOB_ARGS: ${JOB_ARGS}"
70112

@@ -75,8 +117,8 @@ cat $GQL_FILE > /tmp/geaflow/gql/user.gql
75117
CLASSPATH=$CLASSPATH:/tmp/geaflow/gql/
76118

77119
echo "CLASSPATH:$CLASSPATH"
78-
echo -e "\033[32mView dashboard via http://localhost:8090.
79-
See logs via url http://localhost:8090/#/components/master/logs or at local path ${GEAFLOW_LOG_PATH}\033[32m"
120+
echo -e "\033[32mView dashboard via http://localhost:${master_port}.
121+
See logs via url http://localhost:${master_port}/#/components/master/logs or at local path ${GEAFLOW_LOG_PATH}\033[32m"
80122

81123
$JAVACMD -cp "$CLASSPATH" \
82124
-DclusterType=LOCAL \

0 commit comments

Comments
 (0)