You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
source /etc/profile
# 检查java进程是否正常运行中
if pgrep -f "com.dsideal.FengHuang" >/dev/null 2>&1
then
echo "$(date): Java程序已经运行"
else
echo "$(date): Java程序未运行将尝试启动..."
# 进入程序目录
cd /usr/local/tomcat8/webapps/FengHuang/WEB-INF/classes
# 启动入口类,该脚本文件用于别的项目时要改这里
MAIN_CLASS=com.dsideal.FengHuang.Start
# Java 命令行参数,根据需要开启下面的配置,改成自己需要的,注意等号前后不能有空格
export JAVA_HOME=/usr/java/jdk
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
JAVA_OPTS="-Xms1024m -Xmx2048m"
# 生成 class path 值
CP=.:/usr/local/tomcat8/webapps/FengHuang/WEB-INF/lib/*
# 运行为后台进程,并且将信息输出到 logback.xml配置的日志文件位置
nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} >> /usr/local/tomcat8/webapps/FengHuang/WEB-INF/classes/log.log 2>&1 &
echo "$(date): Java程序启动完成"
fi