首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为Pants设置分布式缓存?

如何为Pants设置分布式缓存?
EN

Stack Overflow用户
提问于 2015-09-03 06:53:07
回答 2查看 584关注 0票数 2

在文档站点上,Pants在第一个概念中提到,它支持分布式缓存的概念来缓存已发布的工件。参见https://pantsbuild.github.io/first_concepts.html

我一直在文档中查找设置分布式缓存的步骤,但都没有成功。谁能给我指个正确的方向,告诉我该怎么做?

EN

回答 2

Stack Overflow用户

发布于 2015-09-03 07:05:55

首先看看这是否有帮助:https://pantsbuild.github.io/setup_repo.html#outside-caches并返回报告。

票数 0
EN

Stack Overflow用户

发布于 2016-05-01 20:45:49

首先,您希望设置您的裤子,以便将“好的”值写入缓存。pants.ini不会将增量构建的结果上传到缓存,因此我们通常建议您将CI环境设置为发布到缓存,然后设置这些Pants设置以防止zinc在CI中执行增量构建。

代码语言:javascript
复制
[compile.zinc]
# We don't want to use incremental compile in CI.  This should short-circuit
# some extra work Pants does to support incremental compile.
incremental: False

# Introduce some randomness when choosing the next chunk of work in order
# to share more work between different CI jobs.
size_estimator: random

有两种常用的设置: REST缓存和NFS缓存

如果所有机器都能够访问一个通用的NFS服务器,那么使用NFS会很方便。CI工作进程的配置非常简单:

代码语言:javascript
复制
[cache]
read_from: ["/mnt/nfs/shared-cache/pants-artifact-cache"]
read: True
write_to: ["/mnt/nfs/shared-cache/pants-artifact-cache"]
# For CI builds, turn on writing, but for developer workstations you may
# want to leave this off and mount the NFS dir read-only
write: True
# Turn off auto-purging of the buildcache, leave that to a cron job
max_entries_per_target: 0

下面是作为cronjob安装的清理作业:

代码语言:javascript
复制
echo /usr/sbin/tmpwatch -c 14d /data2/shared-cache/pants-artifact-cache > /etc/cron.daily/pants-cache-clean
chmod +x /etc/cron.daily/pants-cache-clean

如果您想要设置一个使用REST共享的缓存,您可以配置一个服务器来接受PUT和DELETE调用。然后使用URL配置缓存设置,如下所示:

代码语言:javascript
复制
[cache]
read_from: ["https://pantscache.example.com/pants-artifact-cache/ro"]
read: True
write_to: ["https://pantscache.example.com/pants-artifact-cache/rw"]
# For CI builds, turn on writing, but for developer workstations you may
# want to leave this off.
write: True    

请参阅此writeup,了解如何使用Pants设置基本的NGINX。如果你想了解更复杂的缓存设置的详细信息,可以在pants-devel@ group或pantsbuild #general slack组上询问,使用Varnish或多个NGINX服务器进行分片。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32364442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档