springboot一直以来以简单快速著称,在myeclipse上完成部署很容易,运行application.java 就行,但是centos上如何部署
先用maven package完成打包(不能图省事用fatjar会报错)
start.sh
#!/bin/sh
rm -f tpid
nohup java -jar /opt/soft/elasticsearch_mongodb_test-0.0.1-SNAPSHOT.jar> /opt/soft/zhanglu.log 2>&1 &
echo $! > tpid
echo Start Success!
stop.sh
#!/bin/sh
APP_NAME=elasticsearch_mongodb_test-0.0.1-SNAPSHOT
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
chck.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