Rails 开发和生产环境需要重新启动吗?
在开发中,当我更改视图、控制器、路由等时,不需要重新启动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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所有视图控制器和路由都在生产中缓存,以加快应用程序的运行速度。如果必须为每个请求重新加载所有这些内容,那将是一件非常糟糕的事情。这取自development.rb:
此外,您的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:
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 dobundle install
on those as well.开发
服务器可以在每个请求上重新加载代码、视图、控制器和路由,因为您的请求是唯一发送给它的请求 - 如果您< /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 theproduction
server. But the common case of adevelopment
server is constant change.