deploy.sh
1
#
!
/
bin
/
sh
2
3 # 定义变量
4
5 mainpath =/ data / ddc / index-service / cd $ mainpathecho " rm classes "
6
7 # 删除原有的class文件以及lib文件
8
9 rm -rf $ mainpath / classes
10
11 echo " rm lib " rm -rf $ mainpath / lib
12
13 # 解压新的文件,传入文件名称
14
15 tar xvf $ 1 echo " stop service " cd deploy
16
17 # 停掉原有服务
18
19 sh $ mainpath / deploy / stop . sh
20
21 echo " start service " # 开始服务
22
23 sh $ mainpath / deploy / start . sh
2
3 # 定义变量
4
5 mainpath =/ data / ddc / index-service / cd $ mainpathecho " rm classes "
6
7 # 删除原有的class文件以及lib文件
8
9 rm -rf $ mainpath / classes
10
11 echo " rm lib " rm -rf $ mainpath / lib
12
13 # 解压新的文件,传入文件名称
14
15 tar xvf $ 1 echo " stop service " cd deploy
16
17 # 停掉原有服务
18
19 sh $ mainpath / deploy / stop . sh
20
21 echo " start service " # 开始服务
22
23 sh $ mainpath / deploy / start . sh
stop.sh
#
!
/
bin
/
sh
# kill server
# 查找该程序的进程serverID
# kill server
# 查找该程序的进程serverID
#显示所有的进程,查找含有“com.analyse.news.server.NewsServer” 但不含有“grep”的行
#调用awk命令将这一行的第二个参数(既进程的Id)输出
#linux的shell中 | 的含义既是 将上一个命令的输出作为下一个命令的输入 。类似于将上一个命令的输出结果保存在临时文件中,然后下一个命令取用这个临时文件 。
SERVER_PID = `ps auxf | grep " com.analyse.news.server.NewsServer " | grep -v " grep " | awk '{ print $ 2 }'`
echo " news service interface server pid is ${SERVER_PID} "
if [ -n $ SERVER_PID ]
then
kill $ SERVER_PID
echo " $SERVER_PID is killed! "
fi
SERVER_PID = `ps auxf | grep " com.analyse.news.server.NewsServer " | grep -v " grep " | awk '{ print $ 2 }'`
echo " news service interface server pid is ${SERVER_PID} "
if [ -n $ SERVER_PID ]
then
kill $ SERVER_PID
echo " $SERVER_PID is killed! "
fi
startp.sh
#
!
/
bin
/
sh
SERVICE_HOME =/ data / ddc / index-news-service /
cd $ {SERVICE_HOME}
LIB_DIR =$ {SERVICE_HOME} / lib
LOGS_DIR =$ {SERVICE_HOME} / logs
ARCHIVE_SUFFIX = ` date + %Y%m%d-%H%M`
# 定义程序启动的类
MAIN_CLASS = " com.analyse.news.server.NewsServer "
# 一些启动参数的定义
# JAVA_ARGS = " -server -Xms4096m -Xmx5000m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -Xloggc:${SERVICE_HOME}/logs/gc.log "
# JAVA_ARGS = " -server -Xms2048m -Xmx4000m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -XX:PermSize=64M -XX:MaxPermSize=64m -Xdebug -Xrunjdwp:transport=dt_socket,address=1962,server=y,suspend=n -Xloggc:${SERVICE_HOME}/logs/gc.log "
JAVA_ARGS = " -server -Xms4096m -Xmx6144m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -XX:PermSize=64M -XX:MaxPermSize=64m -Xloggc:${SERVICE_HOME}/logs/gc.log -Dcom.sun.management.jmxremote.port=22881 -Dcom.sun.management.jmxremote.pwd.file=jmxremote.pwd -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
JAVA_ARGS = " ${JAVA_ARGS} -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.server.exceptionTrace=true "
JAVA_ARGS = " ${JAVA_ARGS} -Dsun.rmi.transport.tcp.responseTimeout=10000 -Dsun.rmi.transport.tcp.handshakeTimeout=10000 -Dsun.rmi.transport.proxy.connectTimeout=10000 "
# JAVA_ARGS = " ${JAVA_ARGS} -agentpath:/opt/jprofiler6/bin/linux-x64/libjprofilerti.so=port=8849 "
JAVA_ARGS = " ${JAVA_ARGS} -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4444 "
# 把calsses文件夹加入到classpath路径中
CLASSPATH =$ CLASSPATH: $ {SERVICE_HOME} / classes /
# 把lib包中的所有jar包加入到classpath中
files = `ls - 1 $ {LIB_DIR}`
for file in $ { files } ; do
CLASSPATH =$ CLASSPATH: $ {LIB_DIR} /$ {file}
done
# 定义calsspath环境变量
export CLASSPATH
mv $ {LOGS_DIR} / stdout . log $ {LOGS_DIR} / stdout . log .$ {ARCHIVE_SUFFIX}
mv $ {LOGS_DIR} / stderr . log $ {LOGS_DIR} / stderr . log .$ {ARCHIVE_SUFFIX}
mv $ {LOGS_DIR} / gc . log $ {LOGS_DIR} / gc . log .$ {ARCHIVE_SUFFIX}
java $ {JAVA_ARGS} $ {MAIN_CLASS} 1 >$ {SERVICE_HOME} / logs / stdout . log 2 >$ {SERVICE_HOME} / logs / stderr . log&
echo " news service starting... "
SERVICE_HOME =/ data / ddc / index-news-service /
cd $ {SERVICE_HOME}
LIB_DIR =$ {SERVICE_HOME} / lib
LOGS_DIR =$ {SERVICE_HOME} / logs
ARCHIVE_SUFFIX = ` date + %Y%m%d-%H%M`
# 定义程序启动的类
MAIN_CLASS = " com.analyse.news.server.NewsServer "
# 一些启动参数的定义
# JAVA_ARGS = " -server -Xms4096m -Xmx5000m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -Xloggc:${SERVICE_HOME}/logs/gc.log "
# JAVA_ARGS = " -server -Xms2048m -Xmx4000m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -XX:PermSize=64M -XX:MaxPermSize=64m -Xdebug -Xrunjdwp:transport=dt_socket,address=1962,server=y,suspend=n -Xloggc:${SERVICE_HOME}/logs/gc.log "
JAVA_ARGS = " -server -Xms4096m -Xmx6144m -XX:NewSize=64m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=78 -XX:ThreadStackSize=128 -XX:PermSize=64M -XX:MaxPermSize=64m -Xloggc:${SERVICE_HOME}/logs/gc.log -Dcom.sun.management.jmxremote.port=22881 -Dcom.sun.management.jmxremote.pwd.file=jmxremote.pwd -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
JAVA_ARGS = " ${JAVA_ARGS} -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.server.exceptionTrace=true "
JAVA_ARGS = " ${JAVA_ARGS} -Dsun.rmi.transport.tcp.responseTimeout=10000 -Dsun.rmi.transport.tcp.handshakeTimeout=10000 -Dsun.rmi.transport.proxy.connectTimeout=10000 "
# JAVA_ARGS = " ${JAVA_ARGS} -agentpath:/opt/jprofiler6/bin/linux-x64/libjprofilerti.so=port=8849 "
JAVA_ARGS = " ${JAVA_ARGS} -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4444 "
# 把calsses文件夹加入到classpath路径中
CLASSPATH =$ CLASSPATH: $ {SERVICE_HOME} / classes /
# 把lib包中的所有jar包加入到classpath中
files = `ls - 1 $ {LIB_DIR}`
for file in $ { files } ; do
CLASSPATH =$ CLASSPATH: $ {LIB_DIR} /$ {file}
done
# 定义calsspath环境变量
export CLASSPATH
mv $ {LOGS_DIR} / stdout . log $ {LOGS_DIR} / stdout . log .$ {ARCHIVE_SUFFIX}
mv $ {LOGS_DIR} / stderr . log $ {LOGS_DIR} / stderr . log .$ {ARCHIVE_SUFFIX}
mv $ {LOGS_DIR} / gc . log $ {LOGS_DIR} / gc . log .$ {ARCHIVE_SUFFIX}
java $ {JAVA_ARGS} $ {MAIN_CLASS} 1 >$ {SERVICE_HOME} / logs / stdout . log 2 >$ {SERVICE_HOME} / logs / stderr . log&
echo " news service starting... "