最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux實(shí)現(xiàn)項(xiàng)目的自動(dòng)化部署

 更新時(shí)間:2022年07月08日 10:39:14   作者:小旭2021  
這篇文章介紹了Linux實(shí)現(xiàn)項(xiàng)目自動(dòng)化部署的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

一、自動(dòng)化部署git項(xiàng)目

#!/bin/bash
 
# 清除項(xiàng)目進(jìn)程和歷史文件
pkill -f start.py
sleep 1
cd /root/automation |rm -rf testProduce/
 
# 獲取項(xiàng)目最新git代碼(前提服務(wù)器配置好git賬戶)
git clone git@dev.test.com:test_code/testProduce.git
 
# 啟動(dòng)項(xiàng)目
cd testProduce/
nohup /usr/python/bin/python3 start.py &
sleep 3
 
# 檢查是否啟動(dòng)成功
pinfo=`pgrep -af start.py`
if [ -n $pinfo ]
then
  echo "Successfully!!!"
else
  echo "Failed!!!"
fi

二、自動(dòng)化更新git項(xiàng)目

#!/bin/bash
 
# 切換至項(xiàng)目路徑
cd /root/automation
 
# 檢查項(xiàng)目是否有更新
gitinfo=`git pull`
if [[ "${gitinfo}" == "Already up-to-date." ]]
then
  echo "Already up-to-date."
else
  # 重啟項(xiàng)目
  pkill -f start.py
  sleep 1
  nohup /usr/python/bin/python3 start.py &
  sleep 3
 
  # 檢查是否啟動(dòng)成功
  pinfo=`pgrep -af start.py`
  if [ -n $pinfo ]
  then
    echo "Successfully!!!"
  else
    echo "Failed!!!"
  fi

三、自動(dòng)化部署已有項(xiàng)目

#!/bin/bash
 
# 設(shè)置源服務(wù)器信息
username="root"
password="root"
host="10.22.33.44"
dir="/usr/local/app"
 
# 備份當(dāng)前項(xiàng)目(以備回滾)
echo "Saving testProduce..."
now=`date +%Y%m%d%H%M%S`
cd $dir | mkdir -p bak/$now
tar -czvf testProduce.tar.gz testProduce/ testProduce-web/
mv testProduce.tar.gz bak/$now/testProduce.tar.gz
 
# 拷貝項(xiàng)目更新包
echo "Copying testProduce..."
/usr/bin/expect<<EOF
  set timeout 10
  spawn scp -r $username@$host:$dir/testProduce-web/ $dir
  expect "*password:"
  send "$password\r"
  expect eof
 
  spawn scp -r $username@$host:$dir/testProduce/lib $dir/testProduce/
  expect "*password:"
  send "$password\r"
  expect eof
 
  spawn scp $username@$host:$dir/testProduce/testProduce.jar $dir/testProduce/
  expect "*password:"
  send "$password\r"
  expect eof
  #interact
EOF
 
# 重啟項(xiàng)目
echo "Restarting testProduce..."
sh testProduce/restart.sh
sleep 8
 
# 檢查是否啟動(dòng)成功
pinfo=`pgrep -af testProduce.jar`
if [ -n $pinfo ]
then
  echo "Successfully!!!"
else
  echo "Failed!!!"
fi
 
:<<COMMENTBLOCK
  pkill -f testProduce.jar
COMMENTBLOCK

四、自動(dòng)化回滾項(xiàng)目

#!/bin/bash
 
# 清除當(dāng)前項(xiàng)目
echo "Clear..."
rm -rf testProduce* |cd bak
 
# 檢查是否指定回滾版本(默認(rèn)回滾上個(gè)版本,按日期排序,所以此路徑不能有其他文件)
if [ -z $1 ]
then
  vs=`ls -l |sort -r |awk 'NR==2 {print $NF}'`
else
  vs=$1
fi
 
# 回滾項(xiàng)目
echo "Reset>>> $vs"
cd $vs |cp testProduce.tar.gz ../../
tar -zxvf testProduce.tar.gz |rm -f testProduce.tar.gz
 
# 重啟項(xiàng)目
echo "Restarting testProduce..."
sh testProduce/restart.sh
sleep 8
 
# 檢查是否啟動(dòng)成功
pinfo=`pgrep -af testProduce.jar`
if [ -n $pinfo ]
then
  echo "Successfully!!!"
else
  echo "Failed!!!"
fi

到此這篇關(guān)于Linux實(shí)現(xiàn)項(xiàng)目自動(dòng)化部署的文章就介紹到這了。希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

梧州市| 莆田市| 岑巩县| 泸水县| 千阳县| 乌鲁木齐县| 定结县| 孟连| 和林格尔县| 奇台县| 高安市| 崇州市| 边坝县| 凤山市| 越西县| 龙口市| 五家渠市| 舟山市| 芦溪县| 昌江| 信宜市| 信丰县| 阿克| 宜丰县| 云南省| 弋阳县| 绥德县| 庄河市| 无锡市| 屏南县| 即墨市| 宁陕县| 长治县| 金乡县| 湾仔区| 海原县| 逊克县| 鄂伦春自治旗| 新巴尔虎右旗| 肥乡县| 犍为县|