您的位置:首页 > 新闻 > 资讯 > 投资者互动平台_b站搜索2018年发布的视频_百度爱采购竞价_百度关键词优化多少钱一年

投资者互动平台_b站搜索2018年发布的视频_百度爱采购竞价_百度关键词优化多少钱一年

2024/10/7 6:50:17 来源:https://blog.csdn.net/u014087707/article/details/142651633  浏览:    关键词:投资者互动平台_b站搜索2018年发布的视频_百度爱采购竞价_百度关键词优化多少钱一年
投资者互动平台_b站搜索2018年发布的视频_百度爱采购竞价_百度关键词优化多少钱一年

背景

远程部署时spring boot 包,比较大。可以采用依赖库和业务包分离的方式。提供一个脚本进行自动部署

maven 配置分离jar包

 <build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><!-- 导入系统路径包 --><includeSystemScope>true</includeSystemScope><includes><include><groupId>nothing</groupId><artifactId>nothing</artifactId></include></includes></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><configuration><archive><!-- 生成的jar中不要包含pom.xml和pom.properties这两个文件 --><addMavenDescriptor>false</addMavenDescriptor><manifest><addClasspath>true</addClasspath><classpathPrefix>lib/</classpathPrefix><!--这里需要修改为你的项目的主启动类--><mainClass>com.ruoyi.RuoYiApplication</mainClass></manifest></archive></configuration></plugin><!--设置将 lib 拷贝到应用 Jar 外面--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy-lib</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>target/lib</outputDirectory><excludeTransitive>false</excludeTransitive><stripVersion>false</stripVersion><includeScope>runtime</includeScope></configuration></execution></executions></plugin></plugins></build>

部署脚本

#!/bin/bashAppName="smart_engineering_admin.jar"
RemoteUser="root"
RemoteHost="xxx.xxx.xxx.xxx"
JVM_OPTS=" -Dloader.path=smart_engineering/lib -Dserver.port=8080 -Dname=$AppName  -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps  -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"start() {echo "Starting $AppName on $RemoteHost"# 定义一个内嵌的函数来远程查询 PIDquery() {ssh "${RemoteUser}@${RemoteHost}" "ps -ef | grep java | grep '$AppName' | grep -v grep | awk '{print \$2}'"}# 获取远程进程 IDPID=$(query)if [ -n "$PID" ]; thenecho "$AppName is already running on $RemoteHost (pid: $PID)..."elseecho "Starting $AppName on $RemoteHost..."ssh "${RemoteUser}@${RemoteHost}" "nohup java $JVM_OPTS -jar smart_engineering/$AppName > /dev/null 2>&1 &"echo "$AppName started successfully on $RemoteHost."ssh "${RemoteUser}@${RemoteHost}" "tail -f logs/sys-console.log"fi
}sync() {rsync -avc --delete ruoyi-admin/target/lib/ root@xxx.xxx.xxx.xxx:smart_engineering/libscp ruoyi-admin/target/smart_engineering_admin.jar root@xxx.xxx.xxx.xxx:smart_engineering/
}stop() {echo "Stopping $AppName on $RemoteHost"# 定义一个内嵌的函数来远程查询 PIDquery() {ssh "${RemoteUser}@${RemoteHost}" "ps -ef | grep java | grep '$AppName' | grep -v grep | awk '{print \$2}'"}# 获取进程 IDPID=$(query)if [ -n "$PID" ]; thenecho "$AppName (pid:$PID) is running. Sending TERM signal..."ssh "${RemoteUser}@${RemoteHost}" "kill -TERM $PID"# 等待进程退出while [ -n "$PID" ]; dosleep 1PID=$(query)doneecho "$AppName has exited."elseecho "$AppName is already stopped."fi
}sync
stop
sleep 2
start
  • 优点
    • 依赖包不变化不会同步,减少上传的文件
    • 每次都同步业务包,保证准确性
    • 提升发布速度

要求

  • windows 的wsl下可用
  • 需要和服务器配置ssh互信

进一步封装

#!/bin/bash./mvnw -T 1C clean package -P prod./push_run.sh

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com