#!/bin/sh

# java服务中需要的jar文件或classpath路径,如业务程序、第三方jar文件log4j等

ShellAbsPath=$(cd "$(dirname "$0")"; pwd)
BinDir=`dirname $0`
AppName=`basename $0`
AppName=${AppName%.*}

ClassPath=""
WorkPath=$(cd "$(dirname "$0")"; pwd)
RunPath=${WorkPath}/config

ClassName="com.alter.Application"

function getLibs(){
for file in $1/*.jar
do
ClassPath=$file:$ClassPath
done
}

function addPath(){
LibPath=$1:$LibPath
}

function start(){
cd ${RunPath}
#java -server -Xms1024m -Xmx1024m -XX:+UseParallelGC -XX:-UseGCOverheadLimit -classpath ${ClassPath} -Djava.library.path=${ClassPath} ${ClassName} >&1 &
java -server -Xms256m -Xmx256m -XX:+UseParallelGC -XX:-UseGCOverheadLimit -classpath ${ClassPath} -Djava.library.path=${ClassPath} ${ClassName} >/xxx-xx/config/log/log.log &
}

function stop(){
ps -aef| grep ${WorkPath} |grep -v grep|awk '{print $2}'|xargs kill -9
}

function status(){
ps -aef|grep $ClassName|grep ${WorkPath}|grep -v grep

}

getLibs ${ShellAbsPath}/lib
getLibs ${ShellAbsPath}/applib

case "$1" in
start)
start
status
;;
stop)
stop
;;
restart|reload)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0;

相关文章:

  • 2022-02-05
  • 2021-10-21
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2018-07-16
  • 2022-12-23
  • 2021-07-31
猜你喜欢
  • 2022-01-16
  • 2022-02-12
  • 2022-12-23
  • 2021-10-03
  • 2021-11-27
  • 2018-11-30
相关资源
相似解决方案