从文档站点,Pants在First Concepts中提到它支持分布式缓存的概念来缓存已发布的工件。请参阅https://pantsbuild.github.io/first_concepts.html。
我一直在查看文档中有关设置分布式缓存的步骤,但一直没有成功。有人能指出我正确的方向指示吗?
答案 0 :(得分:0)
首先看看这是否有帮助:https://pantsbuild.github.io/setup_repo.html#outside-caches并报告回来。
答案 1 :(得分:0)
首先,您要设置裤子,以便将“好”值写入缓存。 Pants不会将增量构建的结果上传到缓存,因此我们通常建议您将CI环境设置为发布到缓存,然后设置这些pants.ini设置以防止锌在CI中执行增量构建。
[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工作人员的配置非常简单:
[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安装的清理作业:
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配置缓存设置,如下所示:
[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以设置带裤子的基本NGINX。如果你想要使用Varnish或带有分片的多个NGINX服务器的更复杂的缓存设置的详细信息,请询问pants-devel @group或pantsbuild #general slack group。