1 Star 0 Fork 1

wuming/testshell-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
project-start.sh 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
wuming 提交于 2年前 . init
#!/bin/bash
# 项目名称
projectName=test-demo
# 输入git仓库地址
gitUrl=
# 输入git分支
echo "请输入git分支(默认为master):"
read gitBranch
gitBranch=${gitBranch:-master}
# 输入git用户名
echo "请输入git用户名:"
read gitUser
# 输入git密码
echo "请输入git密码:"
read -s gitPass
# 输入应用程序端口
echo "请输入应用程序端口号:"
read port
# 拉取最新代码
echo "正在拉取最新代码..."
cd $projectName
gitUrlWithAuth="https://${gitUser}:${gitPass}@${gitUrl#https://}"
git fetch $gitUrlWithAuth $gitBranch
git checkout $gitBranch
git pull $gitUrlWithAuth $gitBranch
# 使用Maven重新编译
echo "正在使用Maven编译..."
mvn clean package
# 重启应用程序
echo "正在重启应用程序..."
pid=$(lsof -i:$port | awk '{print $2}' | sed -n '2p')
kill -9 $pid
nohup java -jar target/$projectName.jar --server.port=$port &
echo "应用程序已更新并重新启动"
########
# 上面脚本依赖了Git、Maven、lsof的命令,所以在运行上述脚本时,系统应提前安装好了git与maven以及lsof
# 其中lsof是为后续重新项目的时候,查询原有进程的端口将其杀掉,在启动我们的项目。
# Ubuntu安装Git与Maven以及lsof的方式
# sudo apt update
# sudo apt install git
# sudo apt install maven
# sudo apt-get install lsof
# CentOS安装Git与Maven的方式
# sudo yum install git
# sudo yum install maven
# sudo yum install lsof
# 安装完成以后可以使用以下命令进行验证
# git --version
# mvn --version
#
########
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/stevenlisw/testshell-demo.git
git@gitee.com:stevenlisw/testshell-demo.git
stevenlisw
testshell-demo
testshell-demo
master

搜索帮助