您的位置:首页 > 运维架构 > Linux

Linux部署可运行JAR

2017-05-20 00:00 330 查看

前言

一直在ide中敲代码,使用命令行
mvn spring-boot:run
或者
gradlew bootRun
来运行spring boot项目。

部署为可运行的jar

spring boot已经尽可能把需要配置的东西自动化了,我还傻傻的像以前springmvc那样补充各种配置,比如加一个数据源druid。然而大可不必,使用默认的就好,等需求不满足的时候,在进行修改就可以了。
运行方式:

java -jar xxxx.jar


看到比较好的linux脚本:

start.sh

#!/bin/sh

rm -f tpid

nohup java -jar xx.jar --spring.profiles.active=dev > /dev/null 2>&1 &

echo $! > tpid

echo Start Success!

stop.sh

#!/bin/sh
APP_NAME=myapp

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi

check.sh

#!/bin/sh
APP_NAME=myapp

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'App is running.'
else
echo 'App is NOT running.'
fi

kill.sh

#!/bin/sh
APP_NAME=myapp

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux springboot