[英]Capistrano: What are the default linked_dirs in config/deploy.rb for?
When you capify a rails project you get a file config/deploy.rb
which includes a commented out line which creates symlinks from the releases directory to the shared parts of the deployment. 给Rails项目添加
config/deploy.rb
,您会得到一个文件config/deploy.rb
,其中包含注释行,该注释行创建了从releases目录到部署共享部分的符号链接。
# config/deploy.rb
#
# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
Once uncommented what do they do? 一旦不加注释,它们会做什么?
Section written by maintainer of Capistrano (@mattbrictson) Capistrano的维护者(@mattbrictson)撰写的部分
public/assets – in a rolling deployment scenario, some customers may be referencing old asset versions (stylesheets, images, etc.) while other customers reference the new versions. 公共/资产–在滚动部署方案中,某些客户可能正在引用旧资产版本(样式表,图像等),而其他客户可能在引用新版本。 Using a shared assets directory ensures that old versions and new versions reside in the same place and are accessible by the web server.
使用共享资产目录可确保旧版本和新版本位于同一位置,并且可由Web服务器访问。
tmp/cache – The asset compilation step of deployment is really slow if it has to start from scratch. tmp / cache –如果必须从头开始,则部署的资产编译步骤确实很慢。 Using a shared tmp directory means the compilation step can reuse cached artifacts from past compilations, speeding up deployment.
使用共享的tmp目录意味着编译步骤可以重用过去编译中的缓存工件,从而加快部署速度。
tmp/{pids, sockets} – Used by Puma and Unicorn amongst others to manage server state. tmp / {pids,sockets} –由Puma和Unicorn等用于管理服务器状态。 During a deploy, the server is pointing at an old version and then switches to the newly deployed version, potentially without a cold stop/start of the server processes.
在部署期间,服务器指向旧版本,然后切换到新部署的版本,可能不会冷停止/启动服务器进程。 Keeping the pid, and socket files in a shared location facilitates this kind of zero downtime deployment.
将pid和套接字文件保存在共享位置有助于进行这种零停机时间部署。
public/system – Historically, uploaded file attachments are stored here. 公共/系统–历史上,上传的文件附件存储在此处。 If this directory isn't shared, all uploaded files would effectively disappear every time a new version of the app is deployed.
如果不共享此目录,则每次部署新版本的应用程序时,所有上传的文件都会有效消失。
(My Edit: Mentioning Puma as it is now the default web server for rails) (我的编辑:提到Puma,因为它现在是Rails的默认Web服务器)
It doesn't break but it is much slower. 它不会中断,但速度要慢得多。 I used my current project and ran a 'first' and then 'next' deploys.
我使用了当前项目,先运行了“ first”,然后进行了“ next”部署。 If you leave linked_dirs commented out then deploys can be as much as four times slower - the time increase due to not using cached data.
如果您将linked_dirs保留为注释状态,则部署速度可能会降低四倍之多-由于不使用缓存的数据而导致时间增加。
+---------------------+----------------+
| | Deploys (mins) |
+---------------------+----------------+
| | First | Next |
+---------------------+----------------+
| Default linked_dirs | 8.10 | 0.50 |
+---------------------+----------------+
| No linked_dirs | 8.20 | 4.30 |
+---------------------+----------------+
The default symlinks are required by most projects for a 'fast' deployment - remove the comment and Capistrano will handle the rest. 大多数项目都需要默认符号链接来实现“快速”部署-删除注释,Capistrano将处理其余的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.