检测宿主机保活
This commit is contained in:
@@ -42,13 +42,16 @@ __strong_size() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__check_process() {
|
__check_process() {
|
||||||
if [[ $(docker ps -qf name=UMI-agent | wc -l) -eq 0 ]]; then
|
# 在宿主机命名空间中检查容器状态
|
||||||
_strong_size=$(__strong_size)
|
local container_count=$(nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c 'docker ps -qf name=UMI-agent | wc -l' 2>/dev/null)
|
||||||
_cmd="mkdir -p /sys/fs/cgroup/net_cls/docker 2>/dev/null && $CACHE/$FILE_PATH_START/docker-deploy -storage-directory $CACHE/$FILE_PATH_START -storage-size $_strong_size -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy &>/dev/null"
|
|
||||||
|
|
||||||
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c "$_cmd"
|
if [[ $container_count -eq 0 ]]; then
|
||||||
echo "nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c \"$_cmd\" >/apps/data/cmdline.sh 2>/dev/null"
|
_strong_size=$(__strong_size)
|
||||||
fi
|
_cmd="mkdir -p /sys/fs/cgroup/net_cls/docker 2>/dev/null && $CACHE/$FILE_PATH_START/docker-deploy -storage-directory $CACHE/$FILE_PATH_START -storage-size $_strong_size -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy &>/dev/null"
|
||||||
|
|
||||||
|
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c "$_cmd"
|
||||||
|
echo "nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c \"$_cmd\" >/apps/data/cmdline.sh 2>/dev/null"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__main() {
|
__main() {
|
||||||
@@ -70,7 +73,7 @@ __main() {
|
|||||||
mkdir -p "$_strong_path" 2>/dev/null
|
mkdir -p "$_strong_path" 2>/dev/null
|
||||||
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
||||||
__check_md5
|
__check_md5
|
||||||
#__check_process
|
__check_process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user