LotusJeff
(Jeff Cocking)
2025 年1 月 9 日 23:01
1
我刚刚运行了 ./launcher rebuild app,但没有更改系统相关文件。现在我卡在了 Discourse 的闪烁点屏幕上。
我检查了以下内容:
docker ps 显示了 Discourse 应用镜像(看起来正常)。
top 命令显示有活动(看起来正常)。
我可以查看 Sidekiq 状态(看起来正常)。
所以,我又重新构建了应用。
结果一样。
我尝试使用安全模式。关闭了所有东西。没有改变。我仍然收到闪烁点屏幕。
我查看了源代码的每一行。我发现有四个 js 文件不可用。它们是:
有许多缺失的 Javascript 文件。这些是找到的第一个。
初步审查:
文件无法通过我的 CDN 访问。
CDN 从我的 S3 存储桶拉取。
文件不在我的 S3 存储桶中,而所有其他资源都存储在那里。
查看重建结果,我可以看到以下内容。
这 4 个文件已创建并以 js 文件扩展名写入 public/assets/。
这 4 个文件已压缩并以 br.js 文件扩展名保存。
检查我的服务器:
我的服务器上所有 4 个 .js 文件都可用。
.br.js 文件在我的服务器上不可用。
.br.js 文件不在我的 S3 存储桶中。
通过查看重建结果,似乎 after_assets_precompile 活动在我的重建过程中没有发生。我可以手动运行 rake s3:upload_assets,资产会迁移到 S3,一切正常。
我检查了以下内容:
我的 yml 文件通过了格式检查。
我能检查什么来确定为什么 after_assets_precompile 没有作为重建的一部分进行处理?
注意:我正在运行:3.4.0.beta4-dev - 6a50b3d4b4
1 个赞
pfaffman
(Jay Pfaffman)
2025 年1 月 9 日 23:06
2
您是否添加了上传资源的 stanza?
为上传配置 S3 兼容对象存储提供商
Discourse:
配置
为了将 Discourse 静态资源存储在您的对象存储中,请在 app.yml 的 hooks 部分添加此配置:
after_assets_precompile:
- exec:
cd: $home
cmd:
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
您可以在那里找到该 rake 任务,然后在容器内运行它(以节省重新构建的时间)。然后,在编辑 yml 文件后进行一次重新构建。
LotusJeff
(Jeff Cocking)
2025 年1 月 9 日 23:08
3
S3 已在网站上运行了 43 天。 rake 命令是作为 S3 安装的一部分放置在那里的。
该网站已被重建至少 30 次。在此期间,我添加了其他插件和组件。这表明 .js 文件已被添加并填充到 S3 存储桶中。
S3 组件一直运行良好。这是我第一次遇到文件未迁移到 S3 的问题。
我能调查什么来了解为什么文件没有被移动?
有人知道是什么原因导致 after_assets_precompile 未运行吗?
1 个赞
LotusJeff
(Jeff Cocking)
2025 年1 月 10 日 16:41
4
救命!
在重建时,该过程会跳过 app.yml 文件中的以下部分:
after_assets_precompile:
- exec:
cd: $home
cmd:
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
重建后,我可以通过以下方式手动处理命令:
./launcher enter app
rake s3:upload_assets
rake s3:expire_missing_assets
命令运行并处理 S3 的必需文件。
我在 after_assets_precompile 代码中添加了一个 echo 命令。
cmd:
- echo "Beginning of precompile commands"
- sudo -E -u discourse bundle exec rake s3:upload_
echo 语句从未出现在重建输出中。
重建步骤会处理 app.yml 文件中此部分之前和之后的所有步骤。它会处理所有插件和自定义命令。
我已采取以下步骤尝试解决:
移除所有插件
禁用所有组件
查看所有 discourse 日志文件。未发现任何错误指示。
查看基本系统日志文件。未发现任何错误指示。
有人知道重建过程为何会跳过此部分吗?
LotusJeff
(Jeff Cocking)
2025 年1 月 10 日 17:19
5
作为测试,我将 after_assets_precompile 命令移至自定义命令部分。
run:
- exec: echo "Beginning of custom commands"
## If you want to set the 'From' email address for your first registration, uncomment and change:
## After getting the first signup email, re-comment the line. It only needs to run once.
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
## command to password protect the website during work. remove for production.
- exec:
cd: $home
cmd:
- echo "Beginning of precompile commands"
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
- exec: echo "End of custom commands"
命令运行正常,没有出现任何问题。这排除了环境访问或安全问题。
在重建过程中,启动器进程正在跳过 after_assets_precompile 代码。
有人知道是什么原因吗?
1 个赞
Jagster
(Jakke Lehtonen)
2025 年1 月 10 日 17:31
6
不清楚,但我大约 4 小时前重建过,没有任何问题。
1 个赞
Ed_S
(Ed S)
2025 年1 月 10 日 21:54
7
也许您的 yml 文件中存在空格或缩进错误。搜索验证器并检查:[验证 yaml]
Jeff Cocking:
after_assets_precompile:
这不应该是顶级键,它应该在 hooks 下,例如:
hooks:
after_assets_precompile:
- exec:
cd: $home
cmd:
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
3 个赞
LotusJeff
(Jeff Cocking)
2025 年1 月 10 日 23:05
9
这已在第一篇帖子中列出。app.yml 已通过验证,缩进正确。
1 个赞
LotusJeff
(Jeff Cocking)
2025 年1 月 10 日 23:30
10
@supermathie - 你太棒了,视力惊人。你能够发现代码没有缩进两个空格。而且只是从一个代码片段而不是更长的部分。谢谢。
我添加了两个空格,问题就解决了。
我之前运行了 app.yml 通过一个 yml 检查器。测试工具告诉我文件结构良好。它无法告诉我它在功能上是错误的。
正确的代码片段应该是:
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/discourse/discourse-adplugin
- git clone https://github.com/discourse/discourse-affiliate
- git clone https://github.com/discourse/discourse-subscriptions
- git clone https://github.com/discourse/discourse-yearly-review
- git clone https://github.com/discourse/discourse-whos-online
- git clone https://github.com/discourse/discourse-data-explorer
# set internal files for cdn
after_assets_precompile:
- exec:
cd: $home
cmd:
- echo "Beginning of precompile commands"
- sudo -E -u discourse bundle exec rake s3:upload_assets
- sudo -E -u discourse bundle exec rake s3:expire_missing_assets
要记录 app.yml 文件。唯一的高层键是:
templates:
params:
env:
volumes:
hooks:
run:
其他所有内容都应该缩进。
最简单的错误可能最令人沮丧。我生命中的六个小时因为两个空格而浪费了。
我的王国换两个空格。
2 个赞
pfaffman
(Jay Pfaffman)
2025 年1 月 11 日 00:44
11
这种情况我经常遇到。
我另一个特别“喜欢”的是编辑了错误的文件,或者在错误的电脑上编辑了正确的文件。
2 个赞
system
(system)
关闭
2025 年2 月 10 日 00:45
12
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.