Преглед изворни кода

refactor(sh_config.sh): 重构 Arthas 安装函数并优化代码

- 将 echo-arthas-install 函数重命名为 install-arthas
- 移除了多余的 echo 命令,直接执行 Arthas 安装和启动逻辑
- 优化了代码格式,提高了可读性
tianyun пре 5 месеци
родитељ
комит
f944f72ae7
2 измењених фајлова са 15 додато и 16 уклоњено
  1. 1 0
      app/install_arthas.sh
  2. 14 16
      sh_config.sh

+ 1 - 0
app/install_arthas.sh

@@ -0,0 +1 @@
+#!/bin/bash

+ 14 - 16
sh_config.sh

@@ -260,22 +260,20 @@ pid-cmd-ubuntu() {
 	echo ""
 }
 
-function echo-arthas-install() {
-	echo '
-    # 判断是否存在 ~/arthas-boot.jar,如果不存在则下载
-    if [ ! -f ~/arthas-boot.jar ]; then
-        ( cd ~ && curl -O https://arthas.aliyun.com/arthas-boot.jar )
-    fi
-
-    # 判断是否在k8s里面
-    if [[ ! -z "$KUBERNETES_SERVICE_HOST" && ! -z "$KUBERNETES_SERVICE_PORT" ]]; then
-        echo "Running in Kubernetes environment"
-        java -jar ~/arthas-boot.jar 1 --options json-format=true
-    else
-        echo "Not running in Kubernetes environment"
-        java -jar ~/arthas-boot.jar --options json-format=true
-    fi
-    '
+function install-arthas() {
+	# 判断是否存在 ~/arthas-boot.jar,如果不存在则下载
+	if [ ! -f ~/arthas-boot.jar ]; then
+		(cd ~ && curl -O https://arthas.aliyun.com/arthas-boot.jar)
+	fi
+
+	# 判断是否在k8s里面
+	if [[ ! -z "$KUBERNETES_SERVICE_HOST" && ! -z "$KUBERNETES_SERVICE_PORT" ]]; then
+		echo "Running in Kubernetes environment"
+		java -jar ~/arthas-boot.jar 1 --options json-format=true
+	else
+		echo "Not running in Kubernetes environment"
+		java -jar ~/arthas-boot.jar --options json-format=true
+	fi
 }
 alias cparthas='echo-arthas-install | pbcopy'