<commit_before>#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`

CR=`echo -e "\0015\c"`
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | sed -e "s/$CR//g"`
LOGS_FILE=`sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | sed -e "s/$CR//g"`

LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
	LOGS_DIR=`dirname $LOGS_FILE`
else
	LOGS_DIR=$DEPLOY_DIR/logs
fi

KILL_PIDS=`ps  --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" |awk '{print $2}'`
if [ -z "$KILL_PIDS" ]; then
    echo "$SERVER_NAME does not started!"
    exit 1;
fi

if [ "$1" != "skip" ]; then
	DUMP_DATE=`date +%Y%m%d%H%M%S`
	DUMP_DIR=$LOGS_DIR/dump/dubbo-registry-$DUMP_DATE
	if [ ! -d $DUMP_DIR ]; then
		mkdir $DUMP_DIR
	fi
	echo -e "Dumping $SERVER_NAME \c"
	for PID in $KILL_PIDS ; do
		$JAVA_HOME/bin/jstack $PID > $DUMP_DIR/jstack-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jinfo $PID > $DUMP_DIR/jinfo-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jstat -gcutil $PID > $DUMP_DIR/jstat-gcutil-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jstat -gccapacity $PID > $DUMP_DIR/jstat-gccapacity-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap $PID > $DUMP_DIR/jmap-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap -heap $PID > $DUMP_DIR/jmap-heap-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap -histo $PID > $DUMP_DIR/jmap-histo-$PID.dump 2>&1
		echo -e ".\c"
		if [ -r /usr/sbin/lsof ]; then
		/usr/sbin/lsof -p $PID > $DUMP_DIR/lsof-$PID.dump
		echo -e ".\c"
		fi
	done
	if [ -r /usr/bin/sar ]; then
	/usr/bin/sar > $DUMP_DIR/sar.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/uptime ]; then
	/usr/bin/uptime > $DUMP_DIR/uptime.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/free ]; then
	/usr/bin/free -t > $DUMP_DIR/free.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/vmstat ]; then
	/usr/bin/vmstat > $DUMP_DIR/vmstat.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/mpstat ]; then
	/usr/bin/mpstat > $DUMP_DIR/mpstat.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/iostat ]; then
	/usr/bin/iostat > $DUMP_DIR/iostat.dump
	echo -e ".\c"
	fi
	if [ -r /bin/netstat ]; then
	/bin/netstat > $DUMP_DIR/netstat.dump
	echo -e ".\c"
	fi
	echo "OK!"
fi

echo -e "Stopping $SERVER_NAME \c"
for PID in $KILL_PIDS ; do
	echo -e "$PID \c"
	kill $PID > /dev/null 2>&1
done

COUNT=0
while [ $COUNT -lt 1 ]; do    
    echo -e ".\c"
    sleep 1
    COUNT=1
    for PID in $KILL_PIDS ; do
		PID_PS=`ps --no-heading -p $PID`
		if [ -n "$PID_PS" ]; then
			COUNT=0
			break<commit_msg>DUBBO-110 统一startup和shutdown脚本<commit_after>#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`

CR=`echo -e "\0015\c"`
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | sed -e "s/$CR//g"`
LOGS_FILE=`sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | sed -e "s/$CR//g"`

LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
	LOGS_DIR=`dirname $LOGS_FILE`
else
	LOGS_DIR=$DEPLOY_DIR/logs
fi

KILL_PIDS=`ps  --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" |awk '{print $2}'`
if [ -z "$KILL_PIDS" ]; then
    echo "$SERVER_NAME does not started!"
    exit 1;
fi

if [ "$1" != "skip" ]; then
	DUMP_DIR=$LOGS_DIR/dump
	if [ ! -d $DUMP_DIR ]; then
		mkdir $DUMP_DIR
	fi
	DUMP_DATE=`date +%Y%m%d%H%M%S`
	DATE_DIR=$DUMP_DIR/$DUMP_DATE
	if [ ! -d $DATE_DIR ]; then
		mkdir $DATE_DIR
	fi
	echo -e "Dumping $SERVER_NAME \c"
	for PID in $KILL_PIDS ; do
		$JAVA_HOME/bin/jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
		echo -e ".\c"
		$JAVA_HOME/bin/jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
		echo -e ".\c"
		if [ -r /usr/sbin/lsof ]; then
		/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
		echo -e ".\c"
		fi
	done
	if [ -r /usr/bin/sar ]; then
	/usr/bin/sar > $DATE_DIR/sar.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/uptime ]; then
	/usr/bin/uptime > $DATE_DIR/uptime.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/free ]; then
	/usr/bin/free -t > $DATE_DIR/free.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/vmstat ]; then
	/usr/bin/vmstat > $DATE_DIR/vmstat.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/mpstat ]; then
	/usr/bin/mpstat > $DATE_DIR/mpstat.dump
	echo -e ".\c"
	fi
	if [ -r /usr/bin/iostat ]; then
	/usr/bin/iostat > $DATE_DIR/iostat.dump
	echo -e ".\c"
	fi
	if [ -r /bin/netstat ]; then
	/bin/netstat > $DATE_DIR/netstat.dump
	echo -e ".\c"
	fi
	echo "OK!"
fi

echo -e "Stopping $SERVER_NAME \c"
for PID in $KILL_PIDS ; do
	kill $PID > /dev/null 2>&1
done

COUNT=0
while [ $COUNT -lt 1 ]; do    
    echo -e ".\c"
    sleep 1
    COUNT=1
    for PID in $KILL_PIDS ; do
		PID_PS=`ps --no-heading -p $PID`
		if [ -n "$PID_PS" ]; then
			COUNT=0
			break
{'fraction_non_alphanumeric': 0.200996015936255, 'fraction_numerical': 0.014143426294820717, 'mean_word_length': 2.7220163083765754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6346687', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2424, 'n_words': 536}