本文共 4022 字,大约阅读时间需要 13 分钟。
名称 | IP | 软件 | 备注 |
---|---|---|---|
gitlab-server | 10.57.61.138 | gitlab-server | Gitlab 服务器 |
gitlab-common-runner | 10.57.61.11 | gitlab-runner | 公用runner服务器 |
Des-server | 172.21.0.10 | miniconda/supervisor | 项目部署服务器 |
[program:go2cloud_platform]command=/data/miniconda3/envs/go2cloud_platform/bin/python /project/go2cloud_platform/runserver start alluser=rootstdout_logfile=/var/log/go2cloud_platform.logautostart=trueautorestart=truestartsecs=60stopasgroup=trueikillasgroup=truestartretries=1redirect_stderr=true
# 配置yum源curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash# 安装runnersudo yum install -y gitlab-ci-multi-runner
有的项目为开启pipeline,需要手动开启
settings->General->Visibility, project features, permissions->Pipelines 可以配置所有人或此项目到Members可以配置管理Pipelinesettings->CI/CD>Runners
# gitlab runner注册到平台sudo gitlab-ci-multi-runner register
也可以对runner进行配置。
可以勾选Active,runner为公用对时候,暂停Runner不接受新的jobs
如果没有制定tag,可以运行在未指定tag的作业。stages: - clean_env # 清理环境及杀死进程 - deploy_src # 部署源码 - install_dependency # 更新依赖 - restart_server # 重启服务 - check_server # 检测服务 variables: BASE_DIR: "/go2cloud_platform/"job clean_env_job: stage: clean_env script: - ssh -o stricthostkeychecking=no root@172.16.100.2 pkill supervisord || true - ssh -o stricthostkeychecking=no root@172.16.100.2 killall /data/miniconda3/bin/python || true - ssh -o stricthostkeychecking=no root@172.16.100.2 killall /data/miniconda3/envs/go2cloud_platform/bin/python || true - ssh -o stricthostkeychecking=no root@172.16.100.2 rm -rf /project${BASE_DIR}* tags: - 51common-runner only: - dev when: alwaysjob deploy_src_job: stage: deploy_src script: - scp -r /home/gitlab-runner/builds/QFafrHEq/0/devops/${BASE_DIR}* root@172.16.100.2:/project${BASE_DIR} - ssh -o stricthostkeychecking=no root@172.16.100.2 cp /project/config/config.yml /project${BASE_DIR} tags: - 51common-runner only: - dev when: alwaysjob install_dependency_job: stage: install_dependency script: - ssh -o stricthostkeychecking=no root@172.16.100.2 /data/miniconda3/envs/go2cloud_platform/bin/python -m pip install -r /project${BASE_DIR}requirements/requirements.txt tags: - 51common-runner only: - dev when: manualjob restart_server_job: stage: restart_server script: - ssh -o stricthostkeychecking=no root@172.16.100.2 sleep 7 - ssh -o stricthostkeychecking=no root@172.16.100.2 supervisord -c /etc/supervisord.conf - ssh -o stricthostkeychecking=no root@172.16.100.2 ps -ef |grep supervisord |grep -v grep tags: - 51common-runner only: - dev when: alwaysjob check_server_job: stage: check_server script: - ssh -o stricthostkeychecking=no root@172.16.100.2 sleep 7 - ssh -o stricthostkeychecking=no root@172.16.100.2 ps -ef|grep "8088" tags: - 51common-runner only: - dev when: always
在此我们部署服务分为五个步骤
项目中到配置指标和变量可以参考:
转载地址:http://lmzlz.baihongyu.com/