【问题标题】:How can I setup a distributed cache for Pants?如何为 Pants 设置分布式缓存?
【发布时间】:2015-09-02 22:53:06
【问题描述】:

从文档站点中,Pants 在 First Concepts 中提到它支持分布式缓存的概念以缓存已发布的工件。见https://pantsbuild.github.io/first_concepts.html

我一直在文档中寻找设置分布式缓存的步骤,但没有成功。有人能指出正确的方向吗?

【问题讨论】:

    标签: pants


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      首先,您要设置裤子,以便将“好的”值写入缓存。 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 Worker 的配置非常简单:

      [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 以使用 Pants 设置基本的 NGINX。如果您想了解有关使用 Varnish 或多个 NGINX 服务器分片的更复杂缓存设置的详细信息,请咨询pants-devel@ 组或pantsbuild #general slack 组。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-06-22
        • 2015-03-13
        • 2020-09-26
        • 1970-01-01
        • 1970-01-01
        • 2013-07-17
        • 2021-09-26
        相关资源
        最近更新 更多