springboot 快速启动脚本

145 阅读1分钟

文件 start.sh ,内容如下:

profile=pre
port=7070
jar_name=ydz-0.0.1-SNAPSHOT.jar
log_path=ydz.log
debug_port=10010
skywalking_agent_path=/webapp/skywalking/apache-skywalking-apm-bin/agent/skywalking-agent.jar

# 先检查是否已经启动
ps_id=`ps -ef|grep $jar_name |grep -v grep |awk '{print $2}'`

echo "进程id:"$ps_id

if [ ! -n "$ps_id" ];then
  echo "正在启动"
else 
  kill -9 $ps_id
  echo "已经杀死进程,进程id:"$ps_id
fi

if [ "$1" = "debug" ];then
  echo '进入debug模式...'
  nohup java -Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=$debug_port  -Dspring.profiles.active=$profile -Dserver.port=$port -jar $jar_name >>$log_path 2>&1 &
elif [ "$1" = "sky" ];then
  echo "使用skywalking 启动中..."
  nohup java -javaagent:$skywalking_agent_path -jar -Dspring.profiles.active=$profile -Dserver.port=$port $jar_name >>$log_path 2>&1 &
else
  nohup java -jar -Dspring.profiles.active=$profile -Dserver.port=$port $jar_name >>$log_path 2>&1 &
fi

tail -f $log_path

将xxx替换即可。 直接使用: sh start.sh

开启远程debug: sh start.sh debug