Jenkins+gitlab发布Django程序
一、

二、




三、shell
# !/bin/bash
cd /root/upload_file
#git add .
#git commit -m 'other'
# git pull
if [ $mode == "deploy" ];then
git add .
git commit -m 'other'
git checkout $branch
git pull
echo "**********************************************"
echo ‘通过branch部署’
echo "**********************************************"
else
git add .
git commit -m 'other'
git reset --hard $tag
echo "**********************************************"
echo ‘通过tag部署’
echo "**********************************************"
fi
PROCESS=`ps -e | grep gunicorn | awk '{printf "%d
", $1}'`
for i in $PROCESS
do
echo "Kill the gunicorn process [ $i ]"
kill -9 $i
done
echo "finish kill"
sleep 3
nohup /opt/python/bin/gunicorn upload_pro.wsgi -b 0.0.0.0:18000 -w 4 > /dev/null &
echo "New project start"
sleep 5
PROCESS=`ps -e | grep gunicorn | awk '{printf "%d
", $1}'`
for i in $PROCESS
do
echo "The new gunicorn process [ $i ]"
done
echo "success"