码迷,mamicode.com
首页 > 其他好文 > 详细

一个脚本从git上pull 并更新到服务器

时间:2017-10-17 12:17:14      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:enter   let   logs   echo   ash   一个   client   code   pull   

#/bin/bash

cd /src/pid01-beta/

echo "update pid01.."

git pull

if [ $? -ne 0 ]; then
        echo "update pid01(clientErrorCode.json) from git failed"
        exit 1
fi

res=`git pull|grep -c "up-to-date"`

if [ $res -eq 1 ]; then 
        echo "pid01 already latest,quit update"
        exit 1
fi


go build

if [ $? -ne 0 ]; then
        echo "go build failed"
        exit 1
fi

rm -rf /data/wesite/pid01-beta

if [ $? -ne 0 ]; then
        echo "delete old pid01 file failed"
        exit 1
fi


mv /src/pid01-beta/pid01-beta /data/website/

if [ $? -ne 0 ]; then
        echo "move new pid01 file failed"
        exit 1
fi


pidno=`ps aux|grep  pid01|grep -v "grep"|awk {print $2}`

kill -9 $pidno

if [ $? -ne 0 ]; then
        echo "old pid01 kill failed"
        exit 1
fi

sleep 5

pid01pid=`ps aux|grep  pid01|grep -v "grep"|awk {print $2}`

if [ "$pid01pid" ];then 
      echo "new version pid01 is running now"
      
fi

 

一个脚本从git上pull 并更新到服务器

标签:enter   let   logs   echo   ash   一个   client   code   pull   

原文地址:http://www.cnblogs.com/weifeng1463/p/7680093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!