Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
hg-misc-tools
Commits
c84e5170
Commit
c84e5170
authored
Mar 02, 2026
by
one
Browse files
[rocHPL] Improve robustness for resolve_ip
parent
01be5357
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
projects/rocHPL/run-docker.sh
projects/rocHPL/run-docker.sh
+5
-4
No files found.
projects/rocHPL/run-docker.sh
View file @
c84e5170
...
...
@@ -12,6 +12,7 @@ WORKSPACE_DIR="${PWD}" # 修改为主节点的rocHPL目录
# 2. 第一列是物理机hostname或IP,第二列是docker容器hostname
# =====================================================================
MASTER_NODE
=
$(
hostname
)
DOCKER_MASTER
=
node01
WORKER_CONFIG
=
"
node2 node02
node3 node03
...
...
@@ -27,12 +28,12 @@ resolve_ip() {
# Try getent
if
command
-v
getent
>
/dev/null 2>&1
;
then
ip
=
$(
getent ahosts
"
$target
"
2>/dev/null |
awk
'{print $1}'
|
head
-n
1
)
ip
=
$(
getent ahosts
"
$target
"
2>/dev/null |
awk
'{print $1}'
|
head
-n
1
||
true
)
fi
# Try ping
if
[
-z
"
$ip
"
]
&&
command
-v
ping
>
/dev/null 2>&1
;
then
ip
=
$(
ping
-c
1
-n
"
$target
"
2>/dev/null |
awk
-F
'[()]'
'/PING/{print $2}'
)
ip
=
$(
ping
-c
1
-n
"
$target
"
2>/dev/null |
awk
-F
'[()]'
'/PING/{print $2}'
||
true
)
fi
# Fallback to /etc/hosts
...
...
@@ -44,8 +45,8 @@ resolve_ip() {
}
MASTER_IP
=
$(
resolve_ip
${
MASTER_NODE
}
)
DOCKER_ADD_HOSTS
=
"--add-host
node01
:
${
MASTER_IP
}
"
echo
"Master node:
${
MASTER_NODE
}
->
node01
(
${
MASTER_IP
}
)"
DOCKER_ADD_HOSTS
=
"--add-host
${
DOCKER_MASTER
}
:
${
MASTER_IP
}
"
echo
"Master node:
${
MASTER_NODE
}
->
${
DOCKER_MASTER
}
(
${
MASTER_IP
}
)"
WORKER_NODE_ARR
=()
while
read
-r
phys_host std_name rest
;
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment