简体   繁体   English

在Nginx ruby​​ on rails上进行热补丁期间,我可以通过服务器重新启动来重新加载特定文件而不是整个应用程序吗?

[英]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_loadcache_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.

相关问题 如何在Nginx中部署ruby-on-rails应用程序? - How can I deploy ruby-on-rails application in nginx? 使用ruby 2.0.0和Rails 3.2.14的Unicorn热重启 - Unicorn hot restart with ruby 2.0.0 and Rails 3.2.14 我是否需要重新启动服务器:Ruby on Rails - Do I need to restart Server : Ruby on Rails 在 ruby​​ on rails 应用程序中,如何将 3 GB csv 文件上传到服务器上的 pg 数据库 - In ruby on rails application how can i upload 3 GB csv file to the pg database on server 使用Ruby on Rails重新启动Apache服务器 - Apache server restart with Ruby on Rails 使用 webpack dev server 和 rails server 进行 webpack 热重载 - Webpack hot reload using webpack dev server and rails server 如何在 Ruby on Rails 中重新加载当前页面? - How can I reload the current page in Ruby on Rails? 如何在Ruby on Rails中重新加载应用程序类 - How to reload Application Class in Ruby on Rails 如何在本地为 ruby on rails 应用程序将服务器请求超时设置为 30 秒限制? - How can I set server request timeout to 30 seconds limit in local for ruby on rails application? 如何使用Passanger在Nginx上的Rails应用程序上部署ruby - How deploy ruby on rails application on nginx with Passanger
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM