Rails 开发和生产环境需要重新启动吗?

发布于 2024-12-18 02:40:12 字数 177 浏览 0 评论 0原文

在开发中,当我更改视图、控制器、路由等时,不需要重新启动rails服务器,但在生产环境中我们确实需要?是否在内存中保存了某些内容,以便我们需要重新启动?

关于 Gemfile (Gemfile.lock) 中我们需要的所有 Gem 文件,这些 Gem 是在运行 Rails 应用程序时加载(或保存到某个地方),还是按需加载?

In Development when i change the views,controllers, routes, etc. There's no need to restart the rails server, but we do need in Production environment? Is it saving something in the memory so that we need the restart?

And about all the Gem files that we need in Gemfile (Gemfile.lock), are those Gems loaded (or save into somewhere) when we run the rails app, or is it loaded on-demand?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海少女心 2024-12-25 02:40:12

所有视图控制器和路由都在生产中缓存,以加快应用程序的运行速度。如果必须为每个请求重新加载所有这些内容,那将是一件非常糟糕的事情。这取自development.rb:

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

此外,您的gems会在应用程序环境启动时加载。这些通过执行捆绑安装安装到您的全局gem目录中。当您部署到另一台服务器时,您还必须在这些服务器上进行bundle install

All of your views controllers and routes are cached in production to speed the app along. It would be a very bad thing to have to reload all of those for every request. This is taken from development.rb:

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

Also, your gems are loaded when the application environment starts. Those are installed to your global gem directory by doing a bundle install. When you deploy to another server, you have to do bundle install on those as well.

旧人九事 2024-12-25 02:40:12

开发服务器可以在每个请求上重新加载代码、视图、控制器和路由,因为您的请求是唯一发送给它的请求 - 如果您< /em> 必须在更改时重新启动服务器。

然而,所有这些检查都需要重新统计每个文件并检查每个请求的修改时间。这是很多的系统调用。减少系统调用是提高程序运行时间和可扩展性的最佳方法,因此“常见情况”(对相同代码和配置的数百万个请求)在生产服务器中进行了优化。但开发服务器的常见情况是不断变化

The development server can afford to reload code, views, controllers, routes on every request because your requests are the only ones going to it -- and it would take more time for development if you had to restart the server on changes.

However, all those checks require re-stat(2)-ing every single file and checking the modification times on every single request. That is a lot of system calls. Reducing system calls is one top method of improving runtime and scalability of a program, so the "common case" -- millions of requests to the same code and configuration -- is optimized in the production server. But the common case of a development server is constant change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文