Webpacker 找不到静态资源

Webpacker 找不到静态资源

我创建了一个 Mastodon 实例DigitalOcean 的预配置 droplet在 Ubuntu 20.04 上部署 Mastodon 5.3.5 版本。我运行了安装向导,然后立即将其升级到 Mastodon v4,使用官方说明

重启后,Web UI 瘫痪。日志/var/log/syslog包含:

ActionView::Template::Error (Webpacker can't find media/icons/favicon-16x16.png in /home/mastodon/live/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:

接下来是一份很长的 JSON 清单。

以下列出一些未能解决问题的方法:

echo RAILS_SERVE_STATIC_FILES=true >> /home/mastodon/live/.env.production
RAILS_ENV=production bundle exec rails assets:precompile

使用find我找到日志中说找不到的文件。它位于./app/javascript/icons/favicon-16x16.png

那么文件似乎位于错误的位置?或者这是权限问题?

答案1

回答我自己的问题,看来我使用的 DigitalOcean droplet 没有足够的内存来执行升级。我有 2GB 的 RAM,但需要 4GB。

这些说明(我在此复制)来自 GitHub 上的 masukomi)对我有用:

  • 关闭你的 droplet;这当然会暂时阻止任何人访问你的盒子
  • 将 droplet 的大小调整为 4GB RAM(仅使用 CPU + RAM,以便您可以返回)
  • 重新打开 droplet
  • ssh 返回机器(IP 应该没有改变)
su - mastodon
cd ~/live

# probably unnecessary but won't hurt...
git checkout yarn.lock

# clobber the precompiled assets because it probably thinks everything's fine with them
RAILS_ENV=production bundle exec rails assets:clobber
RAILS_ENV=production bundle exec rails assets:precompile

# switch back to the root user
exit

# restart all the mastodon services
systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
# probably unnecessary but won't hurt...
systemctl restart mastodon-streaming

最后,masukomi 指出,你可以将 droplet 切换回之前使用的较小 RAM 大小。感谢Jannik S.为我指出这个答案。

相关内容