[英]During hot patch in nginx ruby on rails can I reload the specific file instead of whole application by server restart?
Sometimes I have to hot patch production code due to an error/bug (mostly in a single file) but I have set eager_load
and cache_classes
to true in the development environment. 有时由于错误/错误(通常在单个文件中),我必须对生产代码进行热补丁,但是在开发环境中,我已经将eager_load
和cache_classes
设置为true。 Because of these two, the server takes around 2 and half minutes to load and the same goes for a hot patch. 由于这两个原因,服务器加载大约需要2分半钟,而热补丁也是如此。
My end goal is to reduce server load time. 我的最终目标是减少服务器加载时间。 One way is to add 'require: false' for gems which are not required when the application starts and then load them later when required. 一种方法是为应用程序启动时不需要的gem添加'require:false',然后在需要时加载它们。 But is it possible reload only the updated file instead of restarting the whole application? 但是有可能只重新加载更新的文件而不是重新启动整个应用程序吗?
I am using an nginx free server (Enterprise nginx version could be a solution which provides zero downtime but is it possible in the version?) 我正在使用免费的Nginx服务器(企业Nginx版本可以是提供零停机时间的解决方案,但是该版本是否可以?)
Buying enterprise version of Nginx will not help you. 购买企业版Nginx不会帮助您。 Nginx is used in pair with Phusion Passenger/Unicorn/Thin. Nginx与Phusion Passenger / Unicorn / Thin结合使用。 Zero downtime deployment should be implemented not in Nginx, but in Passenger/Unicorn. 零停机时间部署不应在Nginx中实施,而应在乘客/独角兽中实施。 I prefer to use Unicorn, it's free, powerful and it supports zero downtime deployment. 我更喜欢使用Unicorn,它是免费的,功能强大的,并且支持零停机时间部署。
In production environment Rails needs to load and cache every file to server HTTP requests quickly, I suggest not change this behavior, changing it will slow down your production. 在生产环境中,Rails需要快速将每个文件加载和缓存到服务器HTTP请求,我建议不要更改此行为,更改它会减慢生产速度。
I strongly suggest not to modify files on the server. 我强烈建议不要修改服务器上的文件。 se Capistrano/Mina for deployment. se Capistrano / Mina进行部署。 Changing files by-hand can break production, and you will definitely have huge downtime. 手动更改文件可能会中断生产,并且肯定会造成巨大的停机时间。
Capistrano can help you to deploy project using one command. Capistrano可以帮助您使用一个命令来部署项目。 Also Capistrano can help you to revert quickly to the previous version if something will go wrong. 如果出现问题,Capistrano还可以帮助您快速还原到以前的版本。
https://www.digitalocean.com/community/tutorials/how-to-set-up-zero-downtime-rails-deploys-using-puma-and-foreman https://www.digitalocean.com/community/tutorials/how-to-set-up-zero-downtime-rails-deploys-using-puma-and-foreman
https://www.devroom.io/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn/ https://www.devroom.io/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.