构建失败,无法下载 MaxMind 地理位置数据库

你好!

我两天前按照这些说明在崭新的 DigitalOcean 机器上安装了 Discourse,一切正常。

昨天我尝试在一台新的 DigitalOcean 机器(Ubuntu 18.03,1GB)上再次安装应用。这两台 VPS 配置相同,但这次安装失败了。

我运行了 ./discourse-setup,回答了问题并等待。我的终端在以下行卡住:#<Thread:0x00005621595f3360@/var/www/discourse/lib/tasks/assets.rake:215 run> terminated with exception (report_on_exception is true):。唯一能释放终端的方法是关闭 SSH 连接并重新连接。

我对 Linux 只有基本了解。
使用 apt-get 更新系统并未带来任何改变。
我发现安装程序在 assets:precompile 任务处卡住。异常来自 /var/www/discourse/lib/tasks/assets.rake:227:in rescue in block (2 levels) in <top (required)>': undefined local variable or method'name' for main:Object (NameError)

安装程序向控制台输出了二进制数据,因此导致卡死。深入排查后我意识到发生了 403 错误,但我找不到目标 URL。

有人有任何建议吗?

从内存和 CPU 的角度来看,你使用的是哪种套餐?

  • 1GB 内存
  • 1 个共享 vCPU,主频 2.3GHz
  • 25GB 固态硬盘

你能在这里提供完整的堆栈跟踪吗?另外,你有任何自定义插件吗?

我在 screen 中运行了 setup 并进行了录制。随后用 xdd 打开了日志文件。我将两段二进制数据替换为 <BINARY_DATA>

#<Thread:0x000055c07c7e8cf8@/var/www/discourse/lib/tasks/assets.rake:215 run> terminated with exception (report_on_exceptionis true):
/var/www/discourse/lib/tasks/assets.rake:227:in `rescue in block (2 levels) in <top (required)>':undefined local variable or method`name' for main:Object (NameError)
from /var/www/discourse/lib/tasks/assets.rake:216:in `block (2 levels) in <top (required)>' /var/www/discourse/lib/file_helper.rb:55:in `block in download':
403 Error:<BINARY_DATA> (OpenURI::HTTPError) <BINARY_DATA>
from /var/www/discourse/lib/final_destination.rb:400:in `block (3 levels) in safe_get'
from /var/www/discourse/lib/final_destination.rb:399:in `catch'
from /var/www/discourse/lib/final_destination.rb:399:in `block (2 levels) in safe_get'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1518:in `block in transport_request'
from /usr/local/lib/ruby/2.6.0/net/http/response.rb:165:in `reading_body'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1517:in `transport_request'
from /usr/local/lib/ruby/2.6.0/net/http.rb:1479:in `request'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/net_patches.rb:9:in `block in request_with_mini_profiler'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/mini_profiler/profiling_methods.rb:39:in `step'
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/net_patches.rb:8:in `request_with_mini_profiler'
from /var/www/discourse/lib/final_destination.rb:371:in `block in safe_get'
from /var/www/discourse/lib/final_destination.rb:415:in `block in safe_session'
from /usr/local/lib/ruby/2.6.0/net/http.rb:920:in `start'
from /usr/local/lib/ruby/2.6.0/net/http.rb:605:in `start'
from /var/www/discourse/lib/final_destination.rb:412:in `safe_session'
from /var/www/discourse/lib/final_destination.rb:363:in `safe_get'
from /var/www/discourse/lib/final_destination.rb:129:in `get'
from /var/www/discourse/lib/file_helper.rb:47:in `download'
from /var/www/discourse/lib/discourse_ip_info.rb:30:in `mmdb_download'
from /var/www/discourse/lib/tasks/assets.rake:218:in `block (3 levels) in <top (required)>'
from /var/www/discourse/lib/tasks/assets.rake:217:in `each'
from /var/www/discourse/lib/tasks/assets.rake:217:in `block (2 levels) in <top (required)>'

安装程序随后执行了一些任务,过程中未出现问题。但在流程结束时出现以下错误:

FAILED--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake assets:precompile'
failed with return #<Process::Status: pid 384 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'..exec
failed with the params {"cd"=>"$home", "hook"=>"assets_precompile",
"cmd"=>["su discourse -c 'bundle exec rake assets:precompile'"]}
f534324ceedf6b1a8a5cc89f38e1c12c2418fb69c71f93f21c0dd2f5ef51483d
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one
./discourse-doctor may help diagnose the problem.

命令 ./discourse-doctor 没有帮助。Doctor 检测到应用无法运行,尝试重建时也卡住了。
我尚未安装任何插件,因为这台机器上从未运行过此应用 :frowning:

您的 IP 被禁止下载 MaxMind 数据库。

编辑 app.yml 文件,在 env 键下添加 DISCOURSE_REFRESH_MAXMIND_DB_DURING_PRECOMPILE_DAYS: 365,然后尝试重新构建。

没问题!:boom::fire::tada:
非常感谢!我需要在 app.yml 中保留这一行,还是在首次成功调用后将其删除?

一旦你移除它,由于你的服务器无法下载更新的数据库,问题会再次出现。

将其设置为 365 天实际上意味着,当我们发布新的基础镜像时(每年两次),它会被更新。

我们确实应该在这里提供一个更清晰的错误提示,目前的错误信息完全无法理解。