最新 Discourse 版本导致重建失败,Redis Port 已被占用

操作系统:Ubuntu 20.04
服务器:vServer 4 核,16 GB
磁盘:SSD 160GB

我最近升级到了最新版本的 Discourse。现在遇到了一个问题:Discourse 报告端口 6379 正在被使用,因此无法构建容器:

当我检查所有正在使用的端口时,该端口实际上是空闲的:

Discourse 的某些检查未能正确识别该端口是空闲的。
在 Docker 中可以看到,只有 Discourse 容器成功启动,其他所有操作都失败了:

这个问题真的变成了一个悖论。
Discourse 在 Docker 中启动了 redis-server 进程,随后却崩溃了,因为它已经启动了该进程:

我在主机上运行着主要的 Redis 安装,但那个实例使用的是 6800 端口,因此不应该产生冲突。

这明显看起来像是检查步骤自身失败了:Redis 成功启动了自身,随后却报告失败,提示“地址已被占用”:

您能分享一下您的 app.yml 文件吗?

好的,没问题,谢谢你的查看 :smiley:。这是我的 app.yml 文件:

## 这是一个全功能、独立的 Discourse Docker 容器模板
##
## 修改此文件后,您必须重新构建
## /var/discourse/launcher rebuild app
##
## 编辑时请*非常*小心!
## YAML 文件对空格或对齐的错误超级敏感!
## 如有需要,请访问 http://www.yamllint.com/ 验证此文件

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## 如果您想添加 Lets Encrypt (https),请取消注释这两行
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口?
## 如果您希望 Discourse 与另一个 Web 服务器(如 Apache 或 nginx)共享端口,
## 请参阅 https://meta.discourse.org/t/17247 了解详情
expose:
  - "12080:80"   # http
  - "12443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最大 25%。
  ## 将基于检测到的 RAM 由 bootstrap 自动设置,或者您可以覆盖
  db_shared_buffers: "4096MB"

  ## 可以改善排序性能,但会增加每个连接的内存使用量
  #db_work_mem: "40MB"

  ## 此容器应使用哪个 Git 版本?(默认:tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 支持多少并发 Web 请求?取决于内存和 CPU 核心数。
  ## 将基于检测到的 CPU 由 bootstrap 自动设置,或者您可以覆盖
  UNICORN_WORKERS: 8

  ## TODO: 此 Discourse 实例将响应的域名
  DISCOURSE_HOSTNAME: discourse.forum

  ## 如果您希望容器以与上述指定的相同主机名(-h 选项)启动,请取消注释
  ## (默认值 "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: 在初始注册时将被设为管理员和开发人员的逗号分隔电子邮件列表
  ## 示例 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'developer@email'

  ## TODO: 用于验证新账户和发送通知的 SMTP 邮件服务器
  DISCOURSE_SMTP_ADDRESS: mailserver
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: email@email
  DISCOURSE_SMTP_PASSWORD: "****"
  #DISCOURSE_SMTP_AUTHENTICATION: plain
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (可选,默认为 true)

  ## 如果您添加了 Lets Encrypt 模板,请取消注释以下行以获取免费 SSL 证书
  #LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

  ## 此 Discourse 实例的 CDN 地址(配置为拉取)
  ## 请参阅 https://meta.discourse.org/t/14857 了解详情
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## Docker 容器是无状态的;所有数据都存储在 /shared 中
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## 插件放在这里
## 请参阅 https://meta.discourse.org/t/19157 了解详情
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/angusmcleod/discourse-question-answer.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/gdpelican/retort.git
          - git clone https://github.com/davidtaylorhq/discourse-whos-online.git
          - git clone https://github.com/vinkas0/discourse-navigation.git
          - git clone https://github.com/discourse/discourse-spoiler-alert.git
          - git clone https://github.com/iunctis/discourse-formatting-toolbar.git
          - git clone https://github.com/discourse/discourse-tooltips.git
          - git clone https://github.com/gdpelican/babble.git
          - git clone https://github.com/paviliondev/discourse-quick-messages.git
          - git clone https://github.com/worldismine/PM-Scanner.git
          - git clone https://github.com/paviliondev/discourse-ratings.git
          - git clone https://github.com/discourse/discourse-calendar.git
          - git clone https://github.com/jannolii/discourse-topic-trade-buttons.git

## 构建后运行的任何自定义命令
run:
  - exec: echo "自定义命令开始"
  ## 如果您想为首次注册设置“发件人”电子邮件地址,请取消注释并修改:
  ## 在收到首次注册邮件后,请重新注释该行。它只需运行一次。
  ##- exec: rails r "SiteSetting.notification_email='email@email"
  - exec: echo "自定义命令结束"

你也能发布完整的重建输出吗?

我相信你看到的这些行在每次重建中都会出现,而且不会以任何方式阻塞重建过程,因为我们只是在两个不同的钩子中确保 Redis 正在运行。你的问题出在其他地方。

没问题。如果您需要其他日志,我可以提供::slight_smile:
由于日志超过 3226 行,超出了论坛发帖限制,我已将其发布到 Pastebin:Discourse Rebuild Log - Pastebin.com

该输出显示重建成功……

您的网站不是在 12080 端口运行吗?

是的,网站已成功重新构建。
我发现了问题所在,也就是为什么网站在我这边无法正常加载。
问题出在 SSL 反向证书上,它没有自动续期,导致网站无法加载图片,这让我误以为是 Redis 缓存出了问题 :man_facepalming:

构建过程中显示了相关提示,但 Redis 服务器运行正常。
在续期 SSL 证书后,网站恢复正常。

感谢您的支持,也为我之前的疏忽表示歉意 :sweat_smile: