springboot项目启动,停止,重启

参考博客

https://www.cnblogs.com/c-h-y/p/10460061.html

打包插件,可以指定启动类

1<build> 2 <plugins> 3 <plugin> 4 <groupId>org.springframework.boot</groupId> 5 <artifactId>spring-boot-maven-plugin</artifactId> 6 </plugin> 7 </plugins> 8 </build> 9 10#!/bin/bash 11#这里可替换为你自己的执行程序,其他代码无需更改 12APP_NAME=code-generator-1.0.0.jar 13 14#使用说明,用来提示输入参数 15usage() { 16 echo "Usage: sh 脚本名.sh [start|stop|restart|status]" 17 exit 1 18} 19 20#检查程序是否在运行 21is_exist(){ 22 pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' ` 23 #如果不存在返回1,存在返回0 24 if [ -z "${pid}" ]; then 25 return 1 26 else 27 return 0 28 fi 29} 30 31#启动方法 32start(){ 33 is_exist 34 if [ $? -eq "0" ]; then 35 echo "${APP_NAME} is already running. pid=${pid} ." 36 else 37 nohup java -jar /mnt/ssd1/project/websocket/$APP_NAME > /mnt/ssd1/project/websocket/websocketserverlog.file 2>&1 & 38 echo "${APP_NAME} start success" 39 fi 40} 41 42#停止方法 43stop(){ 44 is_exist 45 if [ $? -eq "0" ]; then 46 kill -9 $pid 47 else 48 echo "${APP_NAME} is not running" 49 fi 50} 51 52#输出运行状态 53status(){ 54 is_exist 55 if [ $? -eq "0" ]; then 56 echo "${APP_NAME} is running. Pid is ${pid}" 57 else 58 echo "${APP_NAME} is NOT running." 59 fi 60} 61 62#重启 63restart(){ 64 stop 65 start 66} 67 68#根据输入参数,选择执行对应方法,不输入则执行使用说明 69case "$1" in 70 "start") 71 start 72 ;; 73 "stop") 74 stop 75 ;; 76 "status") 77 status 78 ;; 79 "restart") 80 restart 81 ;; 82 *) 83 usage 84 ;; 85esac
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

docker-常用命令

1.帮助启动类命令:systemctlstartdocker启动Dockersystemctlstopdocker停止Dockersystemctlrestartdocker重启Dockersystemctlstatusdocker查看Docker状态systemctlenabledocker开机自启动d

MAVEN打包可执行jar包

<build<plugins<plugin<groupIdorg.apache.maven.plugins</groupId<artifactIdmavenshadeplugin</artifactId<version3.1.0</version

Intellij IDEA中使用MyBatis

1、IDEA创建maven工程(略)2、在maven项目的pom.xml添加mybatisgeneratormavenplugin插件和MySQL数据库驱动依赖<build <plugins  <plugin   <groupIdorg.mybatis.generato

SpringBoot打包部署简单说明

SpringBoot项目打包部署1\.jar包部署添加一个插件<!打包插件<build<plugins<plugin<groupId

Maven配置Spring Boot项目打包,依赖包到lib目录、配置文件到conf目录

<build<plugins<plugin<groupIdorg.apache.maven.plugins</groupId<artifactIdmavenjarplugin</artifactId<configuration