Sinatra 在《Passenger》上的第一次尝试总是失败

发布于 2024-08-18 23:52:24 字数 192 浏览 2 评论 0原文

我有一个小型 Sinatra 应用程序,正在使用 Passenger 在共享托管帐户上运行。但是,在一段时间后第一次访问该应用程序时,我收到一个 Passenger 错误页面,指出该应用程序无法启动。通常是因为找不到 Sinatra。

我假设这只是新实例生成后的正常延迟。但是,有没有办法延迟尝试加载 Siantra,直到 Passenger 完全加载?

I have a small Sinatra app I'm running on a shared hosting account using Passenger. However, the first time the app is accessed after a while, I get a Passenger error page saying the application could not be started. Usually because Sinatra could not be found.

I am assuming this is just a normal delay from when a new instance is spawned. However, is there a way to delay trying to load Siantra until it Passenger has fully loaded?

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

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

发布评论

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

评论(4

少跟Wǒ拽 2024-08-25 23:52:24

我似乎通过在 .htaccess 文件中设置 GEMS_PATH 环境变量解决了该问题。我没有再次遇到该错误。然而!

I seem to have solved the issue by setting the GEMS_PATH environment variable in the .htaccess file. I haven't encountered the error again. YET!

冰之心 2024-08-25 23:52:24

我最近在 Dreamhost 支持下解决了这个问题(不是一次很好的体验),最终他们建议将 gem 冻结到应用程序中。这充其量只是一个部分解决方案,因为它似乎适用于某些宝石,但不适用于其他宝石。

我没有

require 'sinatra'

require 'vendor/gems/sinatra-0.9.4/lib/sinatra'

冻结宝石在其他地方有所介绍,但简单地说:为此做好准备,需要做的事情

mkdir vendor/gems
cd vendor/gems
gem unpack sinatra

由于这一更改,我从未得到启动失败屏幕,将 sinatra 引用为文件无法加载。然而,我仍然得到一些其他宝石,这些宝石需要它们本身或其他宝石的一部分。不太清楚细节,但我正在研究破解已安装的 gems 的想法,以使每个“需求”都直接使用我的“供应商”库中的路径。

I took this up with Dreamhost support recently (not a great experience) and eventually they recommended freezing the gems into the application. This is at best a partial solution, because it seems to work for some gems and not for others.

Instead of

require 'sinatra'

I have:

require 'vendor/gems/sinatra-0.9.4/lib/sinatra'

Freezing gems is covered elsewhere, but briefly: to prepare for this, one needs to do

mkdir vendor/gems
cd vendor/gems
gem unpack sinatra

As a result of this change, I never get the startup failure screen quoting sinatra as the file it can't load. However, I still get it for some other gems which require themselves or parts of other gems. Not too clear about the details, but I'm working on the idea of hacking the installed gems to make every "require" use a path directly out of my "vendor" library.

忱杏 2024-08-25 23:52:24

我想你可能需要添加 Gem.clear_paths!在那里

I think you may need to add Gem.clear_paths! in there

記憶穿過時間隧道 2024-08-25 23:52:24

我有 很久以前就有过类似的问题。更新到较新的 Sinatra gem 对我有帮助 - 您正在运行什么版本?

I had a similar problem a long time ago. Updating to a newer Sinatra gem helped me - what version are you running?

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