@@ -64,7 +64,49 @@ while [ "$1" ]; do
64
64
shift
65
65
done
66
66
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
+ )
68
110
JOB_ARGS=${JOB_ARGS:- ${DEFAULT_JOB_ARGS} }
69
111
echo " JOB_ARGS: ${JOB_ARGS} "
70
112
@@ -75,8 +117,8 @@ cat $GQL_FILE > /tmp/geaflow/gql/user.gql
75
117
CLASSPATH=$CLASSPATH :/tmp/geaflow/gql/
76
118
77
119
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"
80
122
81
123
$JAVACMD -cp " $CLASSPATH " \
82
124
-DclusterType=LOCAL \
0 commit comments