Drone 加速二: 解决Build占用资源过高的问题 (drone v2)

file

发现

突然发现服务器反应慢了,就在granafa瞅了一眼,结果cpu96+,吓了一跳,一想也就是drone跑的没有限制资源使用。drone-runner这个名称有误导,开始以为是在这个容器中build,回念一想它定然是重新开一个container跑,结果一看真的是,所以用docker-compose中的deploy是无法限制资源的。这个所谓的runner更多的是一个agent,事实上一开始它就叫drone-agent,用于创建真正的runner。

CPU和内存限制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
drone-runner:
image: drone/drone-runner-docker:1.8
container_name: drone-runner
ports:
- "3000:3000"
depends_on:
- drone
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:rw
environment:
- TZ=Asia/Shanghai
....
- DRONE_CPU_PERIOD=100000
- DRONE_CPU_QUOTA=150000
- DRONE_MEMORY_LIMIT=500*1024*1024*8
  • DRONE_CPU_PERIOD参数最大值100000,代表一个cpu的使用时间,如果希望单个cpu使用不超过75%则改为75000
  • DRONE_CPU_QUOTA和上面的参数配合使用,代表了所有cpu的使用时间总和,不知为什么没有提供cpus那个参数,会好理解的多
  • DRONE_MEMORY_LIMIT内存限制,这个很好理解,单位是byte,其中500_1024_1024*8代表500MB
作者

Carry

发布于

2022-09-25

更新于

2026-05-23

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
You need to set client_id and slot_id to show this AD unit. Please set it in _config.yml.