无法重建discourse

每当我尝试运行 ./launcher rebuild app 时,都会出现错误。

root@amsaal:~# cd /var/discourse/
root@amsaal:/var/discourse# ./launcher rebuild app
检测到 x86_64 架构。
fatal: No such ref: HEAD
fatal: No such ref: HEAD
正在停止旧容器

  • /usr/bin/docker stop -t 600 app
    app
    2.0.20241203-0251: Pulling from discourse/base
    Digest: sha256:d5d4e6d361d56745e37f2609db58a6970cc9b3fcd26d0b2dcba23d0cb581f067
    Status: Image is up to date for discourse/base:2.0.20241203-0251
    docker.io/discourse/base:2.0.20241203-0251
    /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
    /usr/local/bin/pups --stdin
    docker: invalid reference format: repository name (library/#) must be lowercase.
    See ‘docker run --help’.
    cat: cids/app_bootstrap.cid: No such file or directory
    bootstrap failed with exit code 125
    ** 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.
    Container name cannot be empty
    root@amsaal:/var/discourse#

你检查了启动器存储库的状态吗?

git status

root@amsaal:/var/discourse# git status

尚未提交

未跟踪的文件:
(使用 "git add \u003cfile\u003e…" 将文件纳入下次提交)
.github/
.gitignore
LICENSE
README.md
discourse-doctor
discourse-setup
image/
launcher
rebuild.log
samples/
scripts/
templates/
tests/

未提交任何内容,但存在未跟踪的文件 (使用 "git add" 来跟踪)
root@amsaal:/var/discourse#

您应该看到类似这样的内容:

# git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

所以我想你的 /var/discourse 目录不知何故已损坏 - 不再与仓库连接。您是否以某种方式整理、丢失或重命名了 .git 子文件夹?

1 个赞

我实际上什么都没碰?我该如何解决?

抱歉,我不知道。您有 .git 子目录吗?里面有什么?

在我的例子中,配置文件看起来像这样:

# cat .git/config 
[core]

	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/discourse/discourse_docker.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main

但这仅供参考。我不认为修复方法是编辑配置文件!

1 个赞

我得到了相同的结果

root@amsaal:/var/discourse# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote “origin”]
url = GitHub - discourse/discourse_docker: A Docker image for Discourse
fetch = +refs/heads/:refs/remotes/origin/
[branch “main”]
remote = origin
merge = refs/heads/main

还有 git status

root@amsaal:/var/discourse# git status
On branch main
Your branch is based on ‘origin/main’, but the upstream is gone.
(use “git branch --unset-upstream” to fixup)

Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git restore …” to discard changes in working directory)
modified: .github/workflows/build.yml
modified: LICENSE
modified: README.md
modified: templates/postgres.13.template.yml
modified: templates/postgres.15.template.yml
modified: templates/postgres.template.yml
modified: templates/web.ssl.template.yml
modified: templates/web.template.yml

Untracked files:
(use “git add …” to include in what will be committed)
rebuild.log

no changes added to commit (use “git add” and/or “git commit -a”)

看起来你一定更改了某些内容——你最新的 git status 显示的结果与你之前的报告大相径庭。这真是太神秘了!

那么重新安装 Discourse 能解决它吗?你能建议我如何通过 SSH 进行操作吗?

如果需要完全重新安装,您需要完整的备份(包括 app.yml 文件)以及实例上的全新操作系统。

说明在此处:INSTALL-cloud

最好在新实例上尝试安装。您需要将新 IP 地址添加到 DNS 中的临时子域。或者,如果您不介意停机时间,只需将 DNS 更新为新 IP 地址即可。

您需要对此有所了解,否则就需要帮助。抱歉,我无法提供这方面的帮助。