diff --git a/bistoury-agent-common/pom.xml b/bistoury-agent-common/pom.xml index b9a8987e..65f481ed 100644 --- a/bistoury-agent-common/pom.xml +++ b/bistoury-agent-common/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-agent-common/src/main/java/qunar/tc/bistoury/agent/common/kv/RocksDBStoreImpl.java b/bistoury-agent-common/src/main/java/qunar/tc/bistoury/agent/common/kv/RocksDBStoreImpl.java index a8141238..70c279a2 100644 --- a/bistoury-agent-common/src/main/java/qunar/tc/bistoury/agent/common/kv/RocksDBStoreImpl.java +++ b/bistoury-agent-common/src/main/java/qunar/tc/bistoury/agent/common/kv/RocksDBStoreImpl.java @@ -64,27 +64,12 @@ public class RocksDBStoreImpl implements KvDb { this.rocksDB = TtlDB.open(options, path, ttl, false); LOG.info("open rocks db success, path:{}, ttl:{}", path, ttl); - startCompactRange(); } catch (Exception e) { LOG.error("open rocks db error, path:{}, ttl:{}", path, ttl, e); throw new RuntimeException(e); } } - private void startCompactRange() { - executor.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - try { - LOG.debug("compact range rocks db"); - rocksDB.compactRange(); - } catch (RocksDBException e) { - LOG.error("rocks db compact range error", e); - } - } - }, 30, 30, TimeUnit.MINUTES); - } - private void ensureDirectoryExists(final String path) { File file = new File(path); if (!file.exists() || !file.isDirectory()) { diff --git a/bistoury-agent-task/pom.xml b/bistoury-agent-task/pom.xml index c820f3a9..49d6c1b7 100644 --- a/bistoury-agent-task/pom.xml +++ b/bistoury-agent-task/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-agent/pom.xml b/bistoury-agent/pom.xml index ccf629d7..22d0ea9a 100644 --- a/bistoury-agent/pom.xml +++ b/bistoury-agent/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-application/bistoury-application-api/pom.xml b/bistoury-application/bistoury-application-api/pom.xml index 1685595b..3c027080 100644 --- a/bistoury-application/bistoury-application-api/pom.xml +++ b/bistoury-application/bistoury-application-api/pom.xml @@ -5,7 +5,7 @@ bistoury-application qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-application/bistoury-application-mysql/pom.xml b/bistoury-application/bistoury-application-mysql/pom.xml index db48d88e..681fb4db 100644 --- a/bistoury-application/bistoury-application-mysql/pom.xml +++ b/bistoury-application/bistoury-application-mysql/pom.xml @@ -5,7 +5,7 @@ bistoury-application qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-application/pom.xml b/bistoury-application/pom.xml index b0f37e96..4fb98124 100644 --- a/bistoury-application/pom.xml +++ b/bistoury-application/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-attach-arthas/pom.xml b/bistoury-attach-arthas/pom.xml index 0b847e18..04dc1e6a 100644 --- a/bistoury-attach-arthas/pom.xml +++ b/bistoury-attach-arthas/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-attach-common/pom.xml b/bistoury-attach-common/pom.xml index bacab32a..a67b9a81 100644 --- a/bistoury-attach-common/pom.xml +++ b/bistoury-attach-common/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-clientside-common/pom.xml b/bistoury-clientside-common/pom.xml index cb91f1cd..b2ef002e 100644 --- a/bistoury-clientside-common/pom.xml +++ b/bistoury-clientside-common/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-commands/pom.xml b/bistoury-commands/pom.xml index 21706d2b..6ad32e51 100644 --- a/bistoury-commands/pom.xml +++ b/bistoury-commands/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-common/pom.xml b/bistoury-common/pom.xml index 765c1f40..6f0310a0 100644 --- a/bistoury-common/pom.xml +++ b/bistoury-common/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-common/src/main/java/qunar/tc/bistoury/common/BistouryConstants.java b/bistoury-common/src/main/java/qunar/tc/bistoury/common/BistouryConstants.java index e84df81a..7d05e7ce 100644 --- a/bistoury-common/src/main/java/qunar/tc/bistoury/common/BistouryConstants.java +++ b/bistoury-common/src/main/java/qunar/tc/bistoury/common/BistouryConstants.java @@ -56,7 +56,7 @@ public class BistouryConstants { public static final String SPY_CLASSNAME = "qunar.tc.bistoury.instrument.spy.BistourySpys1"; // todo: 先这么写吧 - public static final String CURRENT_VERSION = "2.0.0"; + public static final String CURRENT_VERSION = "2.0.2"; public static final String BISTOURY_VERSION_LINE_PREFIX = "bistoury version:"; diff --git a/bistoury-decompiler-fernflower/pom.xml b/bistoury-decompiler-fernflower/pom.xml index 582defed..01e9274e 100644 --- a/bistoury-decompiler-fernflower/pom.xml +++ b/bistoury-decompiler-fernflower/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-dist/bin/bistoury-agent.sh b/bistoury-dist/bin/bistoury-agent.sh index 238ddb80..0a453911 100644 --- a/bistoury-dist/bin/bistoury-agent.sh +++ b/bistoury-dist/bin/bistoury-agent.sh @@ -10,14 +10,18 @@ BISTOURY_MAIN="qunar.tc.bistoury.indpendent.agent.Main" . "$BISTOURY_BIN_DIR/bistoury-agent-env.sh" for CMD in "$@";do true; done + APP_PID="" +LOCAL_IP="" -while getopts p:j:c:h opt;do +while getopts p:i:j:c:h opt;do case $opt in p) APP_PID=$OPTARG;; + i) LOCAL_IP=$OPTARG;; j) JAVA_HOME=$OPTARG;; c) BISTOURY_APP_LIB_CLASS=$OPTARG;; h|*) echo "-p 通过-p指定应用进程pid" + echo "-i 通过-i参数指定本机ip" echo "-j 通过-j指定java home" echo "-c 通过-c指定应用依赖的jar包中的一个类(推荐使用公司内部中间件的jar包或Spring相关包中的类,如org.springframework.web.servlet.DispatcherServlet),agent通过该类获取应用jar包路径" echo "-h 通过-h查看命令帮助" @@ -36,6 +40,10 @@ if [[ ! -n $BISTOURY_APP_LIB_CLASS ]]; then exit 0 fi +if [[ -n $LOCAL_IP ]]; then + JAVA_OPTS="$JAVA_OPTS -Dbistoury.local.host=$LOCAL_IP" +fi + if [[ -n $APP_PID ]]; then JAVA_OPTS="$JAVA_OPTS -Dbistoury.user.pid=$APP_PID" fi diff --git a/bistoury-dist/pom.xml b/bistoury-dist/pom.xml index a93bf3ea..10aa452d 100644 --- a/bistoury-dist/pom.xml +++ b/bistoury-dist/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-independent-agent/pom.xml b/bistoury-independent-agent/pom.xml index ff929550..2f638406 100644 --- a/bistoury-independent-agent/pom.xml +++ b/bistoury-independent-agent/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-instrument-agent/pom.xml b/bistoury-instrument-agent/pom.xml index 9eb26f16..c7e333fb 100644 --- a/bistoury-instrument-agent/pom.xml +++ b/bistoury-instrument-agent/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-instrument-agent/src/main/java/qunar/tc/bistoury/instrument/agent/AgentBootstrap2.java b/bistoury-instrument-agent/src/main/java/qunar/tc/bistoury/instrument/agent/AgentBootstrap2.java index d86d5173..17ca8ea3 100644 --- a/bistoury-instrument-agent/src/main/java/qunar/tc/bistoury/instrument/agent/AgentBootstrap2.java +++ b/bistoury-instrument-agent/src/main/java/qunar/tc/bistoury/instrument/agent/AgentBootstrap2.java @@ -130,8 +130,8 @@ private static ClassLoader findUserClassLoader(Instrumentation inst, final Strin // 这个方法和DefaultDebugger里面是一样的,但是这个地方不应该有依赖,所以两边都要写 private static Class findLibClass(Instrumentation inst, final String libClass) { if (libClass == null || "".equals(libClass)) { - ps.println("can not find lib class"); - throw new IllegalStateException("can not find lib class"); + ps.println("can not find lib class, [" + libClass + "]"); + throw new IllegalStateException("can not find lib class, [" + libClass + "]"); } Class[] allLoadedClasses = inst.getAllLoadedClasses(); @@ -140,8 +140,13 @@ private static Class findLibClass(Instrumentation inst, final String libClass return clazz; } } - ps.println("can not find lib class"); - throw new IllegalStateException("can not find lib class"); + ps.println("can not find lib class, [" + libClass + "]"); + ps.println("begin print all loaded classes"); + for (Class allLoadedClass : allLoadedClasses) { + ps.println("[" + allLoadedClass.getName() + "]"); + } + ps.println("end print all loaded classes"); + throw new IllegalStateException("can not find lib class, [" + libClass + "]"); } private static File[] getNonSpyJarFiles(File dir, final List spyJarFiles) { diff --git a/bistoury-instrument-client/pom.xml b/bistoury-instrument-client/pom.xml index f18a4c6f..aaaac92a 100644 --- a/bistoury-instrument-client/pom.xml +++ b/bistoury-instrument-client/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-instrument-client/src/main/java/qunar/tc/bistoury/instrument/client/classpath/DefaultAppLibClassSupplier.java b/bistoury-instrument-client/src/main/java/qunar/tc/bistoury/instrument/client/classpath/DefaultAppLibClassSupplier.java index d83b8900..6d6e738c 100644 --- a/bistoury-instrument-client/src/main/java/qunar/tc/bistoury/instrument/client/classpath/DefaultAppLibClassSupplier.java +++ b/bistoury-instrument-client/src/main/java/qunar/tc/bistoury/instrument/client/classpath/DefaultAppLibClassSupplier.java @@ -41,15 +41,15 @@ private static Class findOneAppLibClass(Instrumentation instrumentation) { Class[] allLoadedClasses = instrumentation.getAllLoadedClasses(); final String libClass = System.getProperty("bistoury.app.lib.class"); if (Strings.isNullOrEmpty(libClass)) { - System.err.println("can not find lib class"); - throw new IllegalStateException("can not find lib class"); + System.err.println("can not find lib class, [" + libClass + "]"); + throw new IllegalStateException("can not find lib class, [" + libClass + "]"); } for (Class clazz : allLoadedClasses) { if (libClass.equals(clazz.getName())) { return clazz; } } - System.err.println("can not find lib class"); - throw new IllegalStateException("can not find lib class"); + System.err.println("can not find lib class, [" + libClass + "]"); + throw new IllegalStateException("can not find lib class, [" + libClass + "]"); } } diff --git a/bistoury-instrument-spy/pom.xml b/bistoury-instrument-spy/pom.xml index b9e3fdea..d4a34d8e 100644 --- a/bistoury-instrument-spy/pom.xml +++ b/bistoury-instrument-spy/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-magic-classes/pom.xml b/bistoury-magic-classes/pom.xml index b288ffd8..a29439b3 100644 --- a/bistoury-magic-classes/pom.xml +++ b/bistoury-magic-classes/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-magic-loader/pom.xml b/bistoury-magic-loader/pom.xml index d90138d7..a77f0515 100644 --- a/bistoury-magic-loader/pom.xml +++ b/bistoury-magic-loader/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-metrics-prometheus/pom.xml b/bistoury-metrics-prometheus/pom.xml index 290b2dc4..4f2e8208 100644 --- a/bistoury-metrics-prometheus/pom.xml +++ b/bistoury-metrics-prometheus/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-proxy/pom.xml b/bistoury-proxy/pom.xml index cfabd531..99bd5702 100644 --- a/bistoury-proxy/pom.xml +++ b/bistoury-proxy/pom.xml @@ -5,7 +5,7 @@ bistoury qunar.tc.bistoury - 2.0.0 + 2.0.2 4.0.0 diff --git a/bistoury-proxy/src/bin/bistoury-proxy.sh b/bistoury-proxy/src/bin/bistoury-proxy.sh index 90ebc453..ea3e8d90 100644 --- a/bistoury-proxy/src/bin/bistoury-proxy.sh +++ b/bistoury-proxy/src/bin/bistoury-proxy.sh @@ -10,10 +10,13 @@ BISTOURY_MAIN="qunar.tc.bistoury.proxy.container.Bootstrap" for CMD in "$@";do true; done -while getopts j: opt;do +LOCAL_IP="" +while getopts j:i:h opt;do case $opt in j) JAVA_HOME=$OPTARG;; - *) echo "-j 通过-j指定java home" + i) LOCAL_IP=$OPTARG;; + h|*) echo "-j 通过-j指定java home" + echo "-i 通过-i参数指定本机ip" echo "-h 通过-h查看命令帮助" exit 0 esac @@ -24,6 +27,11 @@ if [[ "$JAVA_HOME" != "" ]];then else JAVA=java; fi + +if [[ -n $LOCAL_IP ]]; then + JAVA_OPTS="$JAVA_OPTS -Dbistoury.local.host=$LOCAL_IP" +fi + CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/sa-jdi.jar" JAVA_OPTS="$JAVA_OPTS -Xloggc:${BISTOURY_LOG_DIR}/bistoury-gc-${TIMESTAMP}.log -XX:+PrintGC -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BISTOURY_LOG_DIR}" BISTOURY_PID_FILE="$BISTOURY_PID_DIR/bistoury-proxy.pid" diff --git a/bistoury-proxy/src/main/resources.local/spring/database.xml b/bistoury-proxy/src/main/resources.local/spring/database.xml index 5f874ae6..6face886 100644 --- a/bistoury-proxy/src/main/resources.local/spring/database.xml +++ b/bistoury-proxy/src/main/resources.local/spring/database.xml @@ -1,14 +1,16 @@ + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> + + + value="#{h2DataBeseUtil.getUrl()}"/> diff --git a/bistoury-proxy/src/main/webapp/proxy.html b/bistoury-proxy/src/main/webapp/proxy.html index 9ff9b2c0..ff6aaac3 100644 --- a/bistoury-proxy/src/main/webapp/proxy.html +++ b/bistoury-proxy/src/main/webapp/proxy.html @@ -4,9 +4,9 @@ Bistoury Proxy Version - - - + + + diff --git a/docs/cn/quick_start.md b/docs/cn/quick_start.md index 775fa95e..73c05fbd 100644 --- a/docs/cn/quick_start.md +++ b/docs/cn/quick_start.md @@ -77,6 +77,7 @@ quick_start.sh可以设置一些启动参数, |参数名称|是否必填|默认值|说明| |-------|------|-----|---| +|-i |选填|ip中列表的第一个|当本机存在多个ip时,指定一个可用ip| |-j |选填|环境变量JAVA_HOME|指定jdk路径| |-l |选填|/tmp|应用的日志目录,Bistoury命令执行的目录,比如ls,tail等都会默认在此目录下执行| |-p |必填| |应用进程id,因为是脚本快速启动,所以需要使用该参数指定对哪个java进程进行诊断| @@ -87,12 +88,13 @@ quick_start.sh可以设置一些启动参数, - 当端口冲突了怎么解决 -Bistoury快捷部署脚本默认会占用一些端口,其中proxy默认使用9090端口,ui默认使用9091端口,agent和proxy通信默认使用9880端口,ui和proxy通信默认使用9881端口,解决方法如下: +Bistoury快捷部署脚本默认会占用一些端口,其中proxy默认使用9090端口,ui默认使用9091端口,agent和proxy通信默认使用9880端口,ui和proxy通信默认使用9881端口,h2数据库默认使用9092端口,端口冲突解决方法如下: - 修改自己占用的端口 - 9090端口占用修改位置:`bistoury/bistoury-proxy-bin/conf/server.properties`中的`tomcat.port`值和quick_start.sh中`PROXY_TOMCAT_PORT`的值 - 9091端口占用修改位置:`bistoury/bistoury-ui-bin/conf/server.properties`中的`tomcat.port`值 - 9880端口占用修改位置:`bistoury/bistoury-proxy-bin/conf/global.properties`中的`agent.newport`值 - 9881端口占用修改位置:`bistoury/bistoury-proxy-bin/conf/global.properties`中的`server.port`值和quick_start.sh中`PROXY_WEBSOCKET_PORT`的值 + - 9092端口占用修改位置:`bistoury/h2/h2.sh`中的`H2_PORT`的值 - 提示not find proxy for agent - 到agent启动日志中检查agent是否启动成功,检查日志中是否存在`bistoury netty client start success`字样日志,如果没有,检查jvm参数`bistoury.proxy.host`是否配置为正确的proxy域名或ip:prot,如果存在这样的日志(`bistoury netty client start success, ProxyConfig{ip='192.168.2.22', port=9880, heartbeatSec=30}`),按照日志后面的ip到对应的proxy上进行后续检查 diff --git a/pom.xml b/pom.xml index eec52609..03139ecc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ qunar.tc.bistoury bistoury - 2.0.0 + 2.0.2 pom diff --git a/script/h2/h2.sh b/script/h2/h2.sh index 80b855e0..1c280b10 100755 --- a/script/h2/h2.sh +++ b/script/h2/h2.sh @@ -3,15 +3,26 @@ H2_DIR=`pwd` H2_LOG_FILE=$H2_DIR/h2.log H2_PID_FILE=$H2_DIR/h2.pid +BISTOURY_TMP_DIR="/tmp/bistoury" +H2_PORT_FILE="$BISTOURY_TMP_DIR/h2port.conf" + H2_DATA_BASE_URL="/tmp/bistoury/h2/bistoury;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=2;AUTO_SERVER=TRUE;" APP_LOG_DIR="\/tmp" + +LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1` + +H2_PORT=9092; +echo "$H2_PORT">$H2_PORT_FILE + for CMD in "$@";do true; done -while getopts j:l:h opt;do +while getopts i:j:l:h opt;do case $opt in + i) LOCAL_IP=$OPTARG;; j) JAVA_HOME=$OPTARG;; l) APP_LOG_DIR=$OPTARG;; - h|*) echo "-j 通过-j指定java home" + h|*) echo "-i 通过-i指定本机ip" + echo "-j 通过-j指定java home" echo "-l 通过-l指定应用日志目录" echo "-h 通过-h查看命令帮助" exit 0 @@ -31,17 +42,16 @@ start(){ echo "Init datas" #替换数据库初始化文件中的sql - local_ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1` local_host=`hostname` APP_LOG_DIR=` echo $APP_LOG_DIR | sed 's#\/#\\\/#g'` - sed 's/${local_ip}/'$local_ip'/g' data.sql | sed 's/${local_host}/'$local_host'/g'|sed 's/${log_dir}/'$APP_LOG_DIR'/g' >newdata.sql + sed 's/${local_ip}/'$LOCAL_IP'/g' data.sql | sed 's/${local_host}/'$local_host'/g'|sed 's/${log_dir}/'$APP_LOG_DIR'/g' >newdata.sql $JAVA -cp h2-1.4.199.jar org.h2.tools.RunScript -url "jdbc:h2:file:$H2_DATA_BASE_URL" -script ./newdata.sql - #rm -rf newdata.sql + rm -rf newdata.sql echo "Start h2 database" - nohup $JAVA -cp h2*.jar org.h2.tools.Server -ifNotExists> "$H2_LOG_FILE" 2>&1 < /dev/null & + nohup $JAVA -cp h2*.jar org.h2.tools.Server -tcp -tcpPort $H2_PORT -tcpAllowOthers -ifNotExists> "$H2_LOG_FILE" 2>&1 < /dev/null & if [[ $? -eq 0 ]] then @@ -67,6 +77,7 @@ stop(){ else kill -9 $(cat "$H2_PID_FILE") rm "$H2_PID_FILE" + rm "$H2_PORT_FILE" echo "STOPPED" fi } diff --git a/script/quick_start.sh b/script/quick_start.sh index 84cbbb1e..64244309 100755 --- a/script/quick_start.sh +++ b/script/quick_start.sh @@ -16,29 +16,31 @@ BISTOURY_AGENT_DIR="$BISTOURY_BASE_DIR/bistoury-agent-bin" BISTOURY_AGENT_BIN_DIR="$BISTOURY_AGENT_DIR/bin" BISTOURY_AGENT_APP_LIB_CLASS=""; -BISTOURY_PROXY_CONF_DIR="/tmp/bistoury" -BISTOURY_PROXY_CONF_FILE="$BISTOURY_PROXY_CONF_DIR/proxy.conf" +BISTOURY_TMP_DIR="/tmp/bistoury" +BISTOURY_PROXY_CONF_FILE="$BISTOURY_TMP_DIR/proxy.conf" + +LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1` start(){ cd $H2_DATABASE_DIR - ./h2.sh -j $2 -l $APP_LOG_DIR start + ./h2.sh -j $2 -i $LOCAL_IP -l $APP_LOG_DIR start sleep 5 cd $BISTOURY_PROXY_BIN_DIR - ./bistoury-proxy.sh -j $2 start + ./bistoury-proxy.sh -j $2 -i $LOCAL_IP start #等待proxy启动 sleep 5 cd $BISTOURY_AGENT_BIN_DIR if [[ -n $BISTOURY_AGENT_APP_LIB_CLASS ]]; then - ./bistoury-agent.sh -p $1 -j $2 -c "$BISTOURY_AGENT_APP_LIB_CLASS" start + ./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 -c "$BISTOURY_AGENT_APP_LIB_CLASS" start else - ./bistoury-agent.sh -p $1 -j $2 start + ./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 start fi cd $BISTOURY_UI_BIN_DIR - ./bistoury-ui.sh -j $2 start + ./bistoury-ui.sh -j $2 -i $LOCAL_IP start cd $BISTOURY_BASE_DIR } @@ -62,13 +64,15 @@ stop(){ for CMD in "$@";do true; done -while getopts p:j:l:c:h opt;do +while getopts p:i:j:l:c:h opt;do case $opt in p) APP_PID=$OPTARG;; + i) LOCAL_IP=$OPTARG;; j) JAVA_HOME=$OPTARG;; l) APP_LOG_DIR=$OPTARG;; c) BISTOURY_AGENT_APP_LIB_CLASS=$OPTARG;; h|*) echo "-p 通过-p指定应用进程pid" + echo "-i 通过-i指定本机ip" echo "-j 通过-j指定java home" echo "-l 通过-l参数指定应用日志目录,不指定时使用/tmp目录" echo "-c 通过-c指定应用依赖的jar包中的一个类(推荐使用公司内部中间件的jar包或Spring相关包中的类,如org.springframework.web.servlet.DispatcherServlet)" @@ -77,8 +81,8 @@ while getopts p:j:l:c:h opt;do esac done -if [[ ! -w "$BISTOURY_PROXY_CONF_DIR" ]] ; then - mkdir -p "$BISTOURY_PROXY_CONF_DIR" +if [[ ! -w "$BISTOURY_TMP_DIR" ]] ; then + mkdir -p "$BISTOURY_TMP_DIR" fi if [[ "start" == $CMD ]] && [[ ! -n $JAVA_HOME ]]; then @@ -91,12 +95,11 @@ if [[ "start" == $CMD ]] && [[ ! -n $BISTOURY_AGENT_APP_LIB_CLASS ]]; then fi if [[ "start" == $CMD ]] && [[ -n "$APP_PID" && -n "$JAVA_HOME" ]]; then - ln -s $JAVA_HOME /tmp/bistoury/java PROXY_TOMCAT_PORT=9090 PROXY_WEBSOCKET_PORT=9881; - LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1` + echo "$LOCAL_IP:$PROXY_TOMCAT_PORT:$PROXY_WEBSOCKET_PORT">$BISTOURY_PROXY_CONF_FILE - start $APP_PID $JAVA_HOME $BISTOURY_AGENT_APP_LIB_CLASS + start $APP_PID $JAVA_HOME $BISTOURY_AGENT_APP_LIB_CLASS $LOCAL_IP elif [[ "stop" == $CMD ]]; then stop rm -rf $BISTOURY_PROXY_CONF_FILE