系列文章目录
第一章 Ubuntu部署Jenkins服务端
第二章 Linux节点的Python服务自动化构建
第三章 Windows节点Python服务自动化构建
第四章 Vue服务自动化打包构建
第五章 监控服务自动化构建
文章目录
Django项目
if [ -d "$log_path/$JOB_NAME" ];
then
echo "$log_path/$JOB_NAME yes"
else
echo "mkdir $log_path/$JOB_NAME"
mkdir $log_path/$JOB_NAME
fi
echo "is start bus_alarmq: $bus_alarmq_consumer_main"
echo "is start bus_dbq: $bus_dbq_consumer_main"
echo "is start celery_job: $celery_job"
case $deploy_env in
start)
echo "start: uwsgi$python_version"
BUILD_ID=dontKillMe uwsgi$python_version --ini $WORKSPACE/uwsgi-1.0.ini
echo "start: nginx"
BUILD_ID=dontKillMe nginx -c $WORKSPACE/unix-nginx-django-1.0.conf
if $bus_alarmq_consumer_main;
then
echo "start bus_alarmq_consumer_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/bus_alarmq_consumer_main.py >/dev/null 2>&1 &
fi
if $bus_dbq_consumer_main;
then
echo "start bus_dbq_consumer_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/bus_dbq_consumer_main.py >/dev/null 2>&1 &
fi
if $bus_push_main;
then
echo "start bus_push_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/ccy_push_main.py >/dev/null 2>&1 &
fi
if $celery_job;
then
echo "start celery_job"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/manage.py celery beat >/dev/null 2>&1 &
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/manage.py celery worker -c $workers --loglevel=info >/dev/null 2>&1 &
fi
;;
restart)
echo "stop: uwsgi$python_version"
pid=` ps -ef|grep "$WORKSPACE/uwsgi-1.0.ini"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start: uwsgi$python_version"
BUILD_ID=dontKillMe uwsgi$python_version --ini $WORKSPACE/uwsgi-1.0.ini
echo "stop nginx"
pid=` lsof -i:$nginx_port|grep -v "COMMAND"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start: nginx"
BUILD_ID=dontKillMe nginx -c $WORKSPACE/unix-nginx-django-1.0.conf
if $bus_alarmq_consumer_main;
then
echo "stop bus_alarmq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/bus_alarmq_consumer_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start bus_alarmq_consumer_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/bus_alarmq_consumer_main.py >/dev/null 2>&1 &
fi
if $bus_dbq_consumer_main;
then
echo "stop bus_dbq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/bus_dbq_consumer_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start bus_dbq_consumer_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/bus_dbq_consumer_main.py >/dev/null 2>&1 &
fi
if $bus_push_main;
then
echo "stop bus_push_main"
pid=` ps -ef|grep "$WORKSPACE/ccy_push_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start bus_push_main"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/ccy_push_main.py >/dev/null 2>&1 &
fi
if $celery_job;
then
echo "stop bus_dbq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/manage.py celery"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "start celery_job"
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/manage.py celery beat >/dev/null 2>&1 &
BUILD_ID=dontKillMe nohup python$python_version $WORKSPACE/manage.py celery worker -c $workers --loglevel=info >/dev/null 2>&1 &
fi
;;
stop)
echo "stop: uwsgi$python_version"
pid=` ps -ef|grep "$WORKSPACE/uwsgi-1.0.ini"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "stop nginx"
pid=` lsof -i:$nginx_port|grep -v "COMMAND"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
if $bus_alarmq_consumer_main;
then
echo "stop bus_alarmq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/bus_alarmq_consumer_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
fi
if $bus_dbq_consumer_main;
then
echo "stop bus_dbq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/bus_dbq_consumer_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
fi
if $bus_push_main;
then
echo "stop bus_push_main"
pid=` ps -ef|grep "$WORKSPACE/ccy_push_main.py"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
fi
if $celery_job;
then
echo "stop bus_dbq_consumer_main"
pid=` ps -ef|grep "$WORKSPACE/manage.py celery"|grep -v "grep"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
fi
;;
*)
exit
;;
esac
Vue项目
if [ -d "$log_path/$JOB_NAME" ];
then
echo "$log_path/$JOB_NAME yes"
else
echo "mkdir $log_path/$JOB_NAME"
mkdir $log_path/$JOB_NAME
fi
if [ -d "$WORKSPACE/dist" ];
then
echo "rm -r $WORKSPACE/dist "
rm -r $WORKSPACE/dist
fi
case $deploy_env in
start)
echo "npm install && npm run build "
npm install && npm run build
npm rebuild node-sass
echo "start: nginx"
BUILD_ID=dontKillMe nginx -c $WORKSPACE/unix-nginx-vue-1.0.conf
;;
restart)
echo "stop nginx"
pid=` lsof -i:$port|grep -v "COMMAND"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
echo "npm install && npm run build "
npm install && npm run build
npm rebuild node-sass
echo "start: nginx"
BUILD_ID=dontKillMe nginx -c $WORKSPACE/unix-nginx-vue-1.0.conf
;;
stop)
echo "stop nginx"
pid=` lsof -i:$port|grep -v "COMMAND"|awk '{print $2}'`
for id in $pid
do
kill -9 $id
done
;;
*)
exit
;;
esac