Last active
December 10, 2020 05:59
-
-
Save GuoYuefei/06cbfd090ae218e9a3417fcc14b8c2fd to your computer and use it in GitHub Desktop.
go项目的一个travis简单模板
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: go | |
sudo: true | |
### blacklist | |
# branches: | |
# except: | |
# - legacy | |
# - experimental | |
### whitelist | |
branches: | |
only: | |
- master | |
- deploy | |
go: | |
- master | |
env: | |
- GO111MODULE=on GOPROXY=https://goproxy.io,direct | |
services: | |
- rabbitmq | |
- elasticsearch | |
before_install: | |
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-amd64.deb -o elasticsearch.deb | |
- sudo dpkg -i --force-confnew elasticsearch.deb | |
- sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch | |
- sudo systemctl restart elasticsearch | |
addons: | |
apt: | |
update: true | |
packages: | |
- rabbitmq-server | |
ssh_known_hosts: 119.29.5.95 | |
install: | |
- | |
before_script: | |
- sudo rabbitmqctl add_user test test | |
- sudo rabbitmqctl set_permissions -p / test ".*" ".*" ".*" | |
# ES 启动速度比较慢 | |
- sleep 8 | |
# 对rabbitmq和es做准备工作 | |
- go run readyfordistributed.go | |
script: | |
## 编译 | |
- cd distributed && bash script/build.sh | |
## 运行多个实例 | |
- bash script/start_min.sh | |
- sleep 2 | |
# 测试部分 | |
- bash script/test.sh | |
after_success: | |
- cd .. | |
after_failure: | |
- cd .. | |
after_script: | |
- cd distributed | |
- bash script/stop_min.sh | |
before_deploy: | |
- openssl aes-256-cbc -K $encrypted_db2095f63ba3_key -iv $encrypted_db2095f63ba3_iv | |
-in deploy_rsa.enc -out deploy_rsa -d | |
- eval "$(ssh-agent -s)" | |
- chmod 600 deploy_rsa | |
- ssh-add deploy_rsa | |
deploy: | |
provider: script | |
script: bash distributed/script/deploy.sh | |
# skip_cleanup: true | |
on: | |
branch: deploy | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## 本部署脚本不会一并部署rabbitmq、es等 | |
## 仅部署本项目 | |
## 且部署时在部署机子上重新构建,所以需要go、git环境 // 使用这种方法也是因为架构,系统文件版本不同会导致二进制文件无法运行 | |
## 确保在用户目录下有这么几个文件夹 | |
ssh ubuntu@119.29.5.95 "cd ~ ; mkdir -p dos/build/var ; mkdir -p ~/DOStorage1/" | |
### 复制内容 | |
scp -r ./** ubuntu@119.29.5.95:~/DOStorage1/ | |
### 登陆后执行 eeof 可以自定义, 下面指令遇到eeof即停 | |
### | |
ssh ubuntu@119.29.5.95 << eeof | |
cd DOStorage1/distributed && pwd | |
rm -rf build && echo -e "\033[33m Delete build folder, then will build \033[0m" | |
bash script/build.sh | |
echo -e "\033[34m 如果有,则关闭之前运行的程序 \033[0m" | |
cd ~/dos/ && bash stop_min.sh | |
cd - | |
cp -r build ~/dos/ | |
cp script/start_min.sh script/stop_min.sh ~/dos/ | |
cd ~ | |
rm -rf DOStorage1 | |
cd dos | |
echo -e "\033[34m 开启程序 \033[0m" | |
bash start_min.sh | |
exit | |
eeof | |
echo "done!" | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment