APP="data_import"
LOG_BASE="/home/admin/logs"
LOG_DIR="$LOG_BASE/$APP"
export PID_FILE="$LOG_DIR/$APP.pid"
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
export JAVA_HOME=/home/admin/local/jdk1.7.0_79
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_PATH=$JAVA_HOME/bin
export JAVA_OPTS="-Xms1024m -Xmx2048m -XX:MaxPermSize=256m"
export HADOOP_USER_NAME=hdfs
CONFIG_PATH=$(cd "$(dirname "$0")/../config";pwd)
LIB_PATH=$(cd "$(dirname "$0")/../lib";pwd)
ALL_JARS=$(ls "$LIB_PATH")
CLASS_PATH=""
for jar in $ALL_JARS
do
CLASS_PATH="$CLASS_PATH""$LIB_PATH""/""$jar"":"
done
CLASS_PATH=`echo $CLASS_PATH | sed -r 's/^(.*):$/\1/g'`
#!/bin/sh
[ -e `dirname $0`/env.sh ] && . `dirname $0`/env.sh
if [ ! -d "$LOG_DIR" ] ;then
mkdir "$LOG_DIR"
if [ $? -ne 0 ] ;then
echo "Cannot create $LOG_DIR" >&2
exit 1
fi
fi
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
ps -ef | awk '{print $2}' | grep "^$PID$" >/dev/null
if [ $? -eq 0 ]
then
echo "process $PID in running."
exit 1
fi
fi
nohup $JAVA_PATH/java $JAVA_OPTS -cp "$CONFIG_PATH:$CLASS_PATH" com.msxf.ImportServer &> /dev/null &
echo $! > $PID_FILE
PID=`cat $PID_FILE `
echo "process $PID is start ok."
~
#!/bin/sh
[ -e `dirname $0`/env.sh ] && . `dirname $0`/env.sh
PID=`cat $PID_FILE`
kill $PID
n=10
i=1
while [ $n -gt $i ]
do
ps -ef | awk '{print $2}' | grep "^$PID" >/dev/null
if [ $? -eq 0 ]
then
sleep 1
let i+=1
else
echo "stop process $PID succeed."
exit
fi
done
echo "stop process $PID failed."
~
~