首页 > 系统相关 >Linux 配置Tomcat、SpringBoot项目开机自启

Linux 配置Tomcat、SpringBoot项目开机自启

时间:2023-02-03 12:12:00浏览次数:38  
标签:opt SpringBoot Tomcat hnpy jar community sh start 自启

Linux 配置Tomcat、SpringBoot项目开机自启

#java environment 指定java环境
export JAVA_HOME=/home/jdk1.8.0_11
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

# 配置开机自启命令

# tomcat
/opt/tomcat/tomcat8380/bin/startup.sh

# springboot
/opt/hnpy_community/eureka/start.sh
/opt/hnpy_community/acct/start.sh
/opt/hnpy_community/order/start.sh
/opt/hnpy_community/api/start.sh
/opt/hnpy_community/common/start.sh
/opt/hnpy_community/community/start.sh
/opt/hnpy_community/dev/start.sh
/opt/hnpy_community/fee/start.sh
/opt/hnpy_community/job/start.sh
/opt/hnpy_community/oa/start.sh
/opt/hnpy_community/report/start.sh
/opt/hnpy_community/store/start.sh
/opt/hnpy_community/user/start.sh

脚本内容:

nohup java -Xmx2560m -Xms2560m -jar /opt/ncxp/ncxp-20.6.jar --server.port=8088 >> /tmp/ncxp-service.log 2>&1 &

更完善的springboot启动脚本:

#配置jar名称
APP_NAME=xxx.jar

#使用说明,用来提示输入参数
usage() {
echo "Usage: sh 脚本名.sh [start|stop|restart|status]"
exit 1
}

#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1,存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}

#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is already running. pid=${pid} ."
else
nohup java -jar $APP_NAME > log.file 2>&1 &
echo "${APP_NAME} start success"
fi
}

#停止方法
stop(){
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
else
echo "${APP_NAME} is not running"
fi
}

#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is running. Pid is ${pid}"
else
echo "${APP_NAME} is NOT running."
fi
}

#重启
restart(){
stop
start
}

#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac


标签:opt,SpringBoot,Tomcat,hnpy,jar,community,sh,start,自启
From: https://www.cnblogs.com/zhangruifeng/p/17088722.html

相关文章

  • Nginx配置tomcat负载均衡,解决css样式丢失问题
    Nginx配置tomcat负载均衡,解决css样式丢失问题增加location~.*即可http{upstreamgzf{ip_hash;server192.168.2.171:8380;server192.1......
  • springboot连接rabbitmq报错:Failed to check/redeclare auto-delete queue(s).
    问题springboot项目使用​​spring-boot-starter-amqp​​连接rabbitmq时出现报错:Failedtocheck/redeclareauto-deletequeue(s).思路这类问题是因为没有连接上rabbitmq......
  • SpringBoot发送虚拟请求~
    1、创建一个测试用的TestController@RestControllerpublicclassTestController{@GetMapping("/test")publicStringtest(){System.out.println(......
  • springboot(一)
    基础1.介绍与入门1.1介绍SpringBoot是由Pivotal团队提供的全新框架,其设计目的是用来简化Spring应用的初始搭建以及开发过程。Spring程序缺点依赖设置繁琐以前写S......
  • SpringBoot的静态路径映射处理
    springboot的默认静态路径:resources下面的/static;/public;/resources;/META-INF/resources这四个文件路径静态路径的默认映射路径是:/**;意思就是说浏览器......
  • SpringBoot默认的8080端口在哪?
    配置文件中,点击port 进入到ServerProperties类 ServerProperties这个类中,读取配置文件server开头的配置 定位类文件所在位置 找到对应jar包的META-INF下的......
  • springboot上传资源到本地,数据库中存url
    importjava.io.File;importjava.io.IOException;importjava.net.URLEncoder;importjava.util.UUID;importorg.springframework.beans.factory.annotation.Autow......
  • SpringBoot Test - 典型的Springboot test注解说明
     重点汇总1.一个典型的springboottest的class写法: 2.@RunWith(SpringRunner.class)@RunWith,就是一个运行期,顾名思义就是“在XX环境下运行”。@RunWith(JUnit4.c......
  • @SpringBootApplication注解祥解
    @SpringBootApplication注解的详细分析 @SpringBootConfiguration:声明当前是一个配置类@ComponentScan:指出扫描进容器的文件 @EnableAutoConf......
  • SpringBoot下动态数据源
    第一种:Mybatis-Plus的dynamic-datasourceGitee地址:https://gitee.com/baomidou/dynamic-datasource-spring-boot-starter要实现其实很简单,一个注解就可以了1、创建......