Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持windows下运行 #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bistoury-dist/bin/bistoury-agent-env.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -euo pipefail

set +o nounset
BISTOURY_STORY_PATH="$BISTOURY_STORE_DIR"
BISTOURY_PROXY_HOST="127.0.0.1:9090"
BISTOURY_APP_LIB_CLASS="org.springframework.web.servlet.DispatcherServlet"
JAVA_HOME="/tmp/bistoury/java"
test -z "$BISTOURY_PROXY_HOST" && BISTOURY_PROXY_HOST="127.0.0.1:9090"
test -z "$BISTOURY_APP_LIB_CLASS" && BISTOURY_APP_LIB_CLASS="org.springframework.web.servlet.DispatcherServlet"
test -z "$JAVA_HOME" && JAVA_HOME="/tmp/bistoury/java"
JAVA_OPTS="-Dbistoury.store.path=$BISTOURY_STORY_PATH -Dbistoury.proxy.host=$BISTOURY_PROXY_HOST"
6 changes: 3 additions & 3 deletions bistoury-dist/bin/bistoury-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ BISTOURY_BIN="$(dirname "$BISTOURY_BIN")"
BISTOURY_BIN_DIR="$(cd "$BISTOURY_BIN"; pwd)"
BISTOURY_MAIN="qunar.tc.bistoury.indpendent.agent.Main"

. "$BISTOURY_BIN_DIR/base.sh"
. "$BISTOURY_BIN_DIR/bistoury-agent-env.sh"

for CMD in "$@";do true; done

APP_PID=""
Expand All @@ -29,6 +26,9 @@ while getopts p:i:j:c:h opt;do
esac
done

. "$BISTOURY_BIN_DIR/base.sh"
. "$BISTOURY_BIN_DIR/bistoury-agent-env.sh"

if [[ "$JAVA_HOME" != "" ]];then
JAVA="$JAVA_HOME/bin/java"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@
* @describe
*/
public class H2DataBeseUtil {
private static final String portPath = "/tmp/bistoury/h2port.conf";
private static final String BISTOURY_TMP_DIR;
static {
String tmp = System.getenv("BISTOURY_TMP_DIR");
BISTOURY_TMP_DIR = tmp == null || tmp.length() < 1 ? "/tmp/bistoury" : tmp;
}
private static final String portPath = BISTOURY_TMP_DIR + "/h2port.conf";

public String getUrl() {
try {
String port = getPort();
return "jdbc:h2:tcp://localhost:" + port + "//tmp/bistoury/h2/bistoury;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=2;AUTO_SERVER=TRUE;";
return "jdbc:h2:tcp://localhost:" + port + "/" + BISTOURY_TMP_DIR + "/h2/bistoury;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=2;AUTO_SERVER=TRUE;";
} catch (Exception e) {
System.err.println("获取h2端口失败,使用默认端口:9092\n" + e);
}
return "jdbc:h2:tcp://localhost//tmp/bistoury/h2/bistoury;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=2;AUTO_SERVER=TRUE;";
return "jdbc:h2:tcp://localhost/" + BISTOURY_TMP_DIR + "/h2/bistoury;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=2;AUTO_SERVER=TRUE;";
}

public static String getPort() throws IOException {
Expand Down
4 changes: 2 additions & 2 deletions bistoury-ui/src/bin/bistoury-ui-env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail

JAVA_HOME="/tmp/bistoury/java"
set +o nounset
test -z "$JAVA_HOME" && JAVA_HOME="/tmp/bistoury/java"
JAVA_OPTS="-Dbistoury.conf=$BISTOURY_COF_DIR -Dbistoury.cache=$BISTOURY_CACHE_DIR"
10 changes: 5 additions & 5 deletions script/h2/h2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
H2_DIR=`pwd`
H2_LOG_FILE=$H2_DIR/h2.log
H2_PID_FILE=$H2_DIR/h2.pid
BISTOURY_TMP_DIR="/tmp/bistoury"
test -z "$BISTOURY_TMP_DIR" && 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;"
H2_DATA_BASE_URL="${BISTOURY_TMP_DIR}/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

Expand All @@ -29,6 +27,8 @@ while getopts i:j:l:h opt;do
esac
done

test -z "$LOCAL_IP" && LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1`

if [[ "$JAVA_HOME" != "" ]];then
JAVA="$JAVA_HOME/bin/java"
else
Expand All @@ -44,7 +44,7 @@ start(){
#替换数据库初始化文件中的sql
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

Expand Down
23 changes: 12 additions & 11 deletions script/quick_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BISTOURY_BASE_DIR=`pwd`

H2_DATABASE_DIR="$BISTOURY_BASE_DIR/h2"

APP_LOG_DIR="/tmp"
test -z "${APP_LOG_DIR}" && APP_LOG_DIR="/tmp"

BISTOURY_UI_DIR="$BISTOURY_BASE_DIR/bistoury-ui"
BISTOURY_UI_BIN_DIR="$BISTOURY_UI_DIR/bin"
Expand All @@ -16,11 +16,9 @@ BISTOURY_AGENT_DIR="$BISTOURY_BASE_DIR/bistoury-agent"
BISTOURY_AGENT_BIN_DIR="$BISTOURY_AGENT_DIR/bin"
BISTOURY_AGENT_APP_LIB_CLASS="";

BISTOURY_TMP_DIR="/tmp/bistoury"
test -z "$BISTOURY_TMP_DIR" && 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
Expand All @@ -32,11 +30,13 @@ start(){
#等待proxy启动
sleep 5

cd $BISTOURY_AGENT_BIN_DIR
if [[ -n $BISTOURY_AGENT_APP_LIB_CLASS ]]; then
./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 -c "$BISTOURY_AGENT_APP_LIB_CLASS" start
else
./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 start
if [ -n "$1" ] ; then
cd $BISTOURY_AGENT_BIN_DIR
if [[ -n $BISTOURY_AGENT_APP_LIB_CLASS ]]; then
./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 -c "$BISTOURY_AGENT_APP_LIB_CLASS" start
else
./bistoury-agent.sh -p $1 -i $LOCAL_IP -j $2 start
fi
fi

cd $BISTOURY_UI_BIN_DIR
Expand Down Expand Up @@ -81,6 +81,7 @@ while getopts p:i:j:l:c:h opt;do
esac
done

test -z "$LOCAL_IP" && LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|tail -1`
if [[ ! -w "$BISTOURY_TMP_DIR" ]] ; then
mkdir -p "$BISTOURY_TMP_DIR"
fi
Expand All @@ -94,12 +95,12 @@ if [[ "start" == $CMD ]] && [[ ! -n $BISTOURY_AGENT_APP_LIB_CLASS ]]; then
echo "没有指定-c参数,agent将通过org.springframework.web.servlet.DispatcherServlet获取应用jar包路径"
fi

if [[ "start" == $CMD ]] && [[ -n "$APP_PID" && -n "$JAVA_HOME" ]]; then
if [[ "start" == $CMD ]] && [[ -n "$JAVA_HOME" ]]; then
PROXY_TOMCAT_PORT=9090
PROXY_WEBSOCKET_PORT=9881;

echo "$LOCAL_IP:$PROXY_TOMCAT_PORT:$PROXY_WEBSOCKET_PORT">$BISTOURY_PROXY_CONF_FILE
start $APP_PID $JAVA_HOME $BISTOURY_AGENT_APP_LIB_CLASS $LOCAL_IP
start "$APP_PID" $JAVA_HOME $BISTOURY_AGENT_APP_LIB_CLASS $LOCAL_IP
elif [[ "stop" == $CMD ]]; then
stop
rm -rf $BISTOURY_PROXY_CONF_FILE
Expand Down