ArgumentError: pid=/.../unicorn.pid 的目录不可写

我正在尝试在一台服务器上设置 Discourse。我以前已经做过几次了,因为我正在测试一个脚本来修复 18 年邮件列表活动 mbox 存档的各个方面,然后再将其导入 Discourse。它以前是有效的。

在暂停工作一段时间后,我运行了 ./discourse-setup,但由于之前尝试次数过多,遇到了 Let’s Encrypt 的错误。为了解决这个问题,我编辑了 containers/app.yml 来删除两个 Let’s Encrypt 模板(我的测试不需要 HTTPS),然后运行了 ./launcher rebuild app

不幸的是,现在访问该网站时出现“502 Bad gateway – nginx”错误。./launcher logs app 的输出包含一堆这些错误:

/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:104:in `block in reload': directory for pid=/var/www/discourse/tmp/pids/unicorn.pid not writable (ArgumentError)

            raise ArgumentError, "directory for #{var}=#{path} not writable"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `each'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `reload'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
config/unicorn_launcher: line 71: kill: (90) - No such process
config/unicorn_launcher: line 15: kill: (90) - No such process
(80) exiting

鉴于它以前是有效的,这可能有几个原因:

  • Discourse 最近的更改。
  • 我没有使用 Let’s Encrypt。
  • 我还更改了电子邮件设置(尽管我不认为这很重要)。

有什么帮助吗?谢谢。

使用不同的子域。我认为 discourse 不再支持 http。

:frowning:

如果这是预期的,难道不应该删除跳过 SSL 的选项吗?我的意思是,没有配置选项总比一个无效的配置选项要好……

不。您可能运行了一个管理证书的外部代理。

那个不可写错误很奇怪。这似乎与证书问题是另一个问题。

您的磁盘没有满,对吗?

没有,没有满。

root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           193M  1.1M  192M   1% /run
/dev/vda1        78G   11G   67G  14% /
tmpfs           965M     0  965M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/vda15      105M  6.1M   99M   6% /boot/efi
overlay          78G   11G   67G  14% /var/lib/docker/overlay2/fa186c119fd0bc36dfbec9d7541b325bc8b099ff7aae53661aa992c66fb61c95/merged
tmpfs           193M  4.0K  193M   1% /run/user/0
1 个赞

我发现我可以使用 Let’s Encrypt 的测试设备,我通过以下 diff 做到了这一点:

diff --git a/templates/web.letsencrypt.ssl.template.yml b/templates/web.letsencrypt.ssl.template.yml
index ba5f551..17e5614 100644
--- a/templates/web.letsencrypt.ssl.template.yml
+++ b/templates/web.letsencrypt.ssl.template.yml
@@ -16,7 +16,7 @@ hooks:
          - install -d -m 0755 -g root -o root $LETSENCRYPT_DIR
          - cd /root/acme.sh && LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --install --log "${LETSENCRYPT_DIR}/acme.sh.log"
          - cd /root/acme.sh && LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --upgrade --auto-upgrade
-         - cd /root/acme.sh && LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --set-default-ca  --server  letsencrypt
+         - cd /root/acme.sh && LE_WORKING_DIR="${LETSENCRYPT_DIR}" ./acme.sh --set-default-ca  --server  letsencrypt_test

     - file:
        path: "/etc/nginx/letsencrypt.conf"

现在,证书似乎没问题了,但错误仍然存在,这表明它确实是无关的。

[Mon 14 Aug 2023 10:55:24 AM UTC] Your cert is in: /shared/letsencrypt/lilypond.community_ecc/lilypond.community.cer
[Mon 14 Aug 2023 10:55:24 AM UTC] Your cert key is in: /shared/letsencrypt/lilypond.community_ecc/lilypond.community.key
[Mon 14 Aug 2023 10:55:24 AM UTC] The intermediate CA cert is in: /shared/letsencrypt/lilypond.community_ecc/ca.cer
[Mon 14 Aug 2023 10:55:24 AM UTC] And the full chain certs is there: /shared/letsencrypt/lilypond.community_ecc/fullchain.cer
[Mon 14 Aug 2023 10:55:25 AM UTC] Installing key to: /shared/ssl/lilypond.community_ecc.key
[Mon 14 Aug 2023 10:55:25 AM UTC] Installing full chain to: /shared/ssl/lilypond.community_ecc.cer
[Mon 14 Aug 2023 10:55:25 AM UTC] Run reload cmd: sv reload nginx
warning: nginx: unable to open supervise/ok: file does not exist
[Mon 14 Aug 2023 10:55:25 AM UTC] Reload error for :
C = US, O = (STAGING) Let's Encrypt, CN = (STAGING) Artificial Apricot R3
error 2 at 1 depth lookup: unable to get issuer certificate
C = US, O = (STAGING) Let's Encrypt, CN = (STAGING) Ersatz Edamame E1
error 2 at 1 depth lookup: unable to get issuer certificate
Started runsvdir, PID is 6029
ok: run: redis: (pid 6040) 0s
ok: run: postgres: (pid 6041) 0s
supervisor pid: 6039 unicorn pid: 6062
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:104:in `block in reload': directory for pid=/var/www/discourse/tmp/pids/unicorn.pid not writable (ArgumentError)

            raise ArgumentError, "directory for #{var}=#{path} not writable"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `each'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `reload'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:78:in `initialize'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `new'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `initialize'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `new'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
        from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
config/unicorn_launcher: line 71: kill: (6062) - No such process
config/unicorn_launcher: line 15: kill: (6062) - No such process
(6039) exiting

我不确定接下来该怎么做。

Just to check, now that my Let’s Encrypt quota limitation has expired, I tried without applying the patch above. This is what I got:

[Mon 14 Aug 2023 07:57:34 PM UTC] Your cert is in: /shared/letsencrypt/lilypond.community_ecc/lilypond.community.cer
[Mon 14 Aug 2023 07:57:34 PM UTC] Your cert key is in: /shared/letsencrypt/lilypond.community_ecc/lilypond.community.key
[Mon 14 Aug 2023 07:57:34 PM UTC] The intermediate CA cert is in: /shared/letsencrypt/lilypond.community_ecc/ca.cer
[Mon 14 Aug 2023 07:57:34 PM UTC] And the full chain certs is there: /shared/letsencrypt/lilypond.community_ecc/fullchain.cer
[Mon 14 Aug 2023 07:57:34 PM UTC] Installing key to: /shared/ssl/lilypond.community_ecc.key
[Mon 14 Aug 2023 07:57:34 PM UTC] Installing full chain to: /shared/ssl/lilypond.community_ecc.cer
[Mon 14 Aug 2023 07:57:34 PM UTC] Run reload cmd: sv reload nginx
warning: nginx: unable to open supervise/ok: file does not exist
[Mon 14 Aug 2023 07:57:34 PM UTC] Reload error for :
C = US, O = (STAGING) Let's Encrypt, CN = (STAGING) Artificial Apricot R3
error 2 at 1 depth lookup: unable to get issuer certificate
C = US, O = (STAGING) Let's Encrypt, CN = (STAGING) Ersatz Edamame E1
error 2 at 1 depth lookup: unable to get issuer certificate
Started runsvdir, PID is 6029
ok: run: redis: (pid 6038) 0s
ok: run: postgres: (pid 6041) 0s
supervisor pid: 6042 unicorn pid: 6062
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:104:in `block in reload': directory for pid=/var/www/discourse/tmp/pids/unicorn.pid not writable (ArgumentError)

            raise ArgumentError, "directory for #{var}=#{path} not writable"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `each'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `reload'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
config/unicorn_launcher: line 71: kill: (6062) - No such process
config/unicorn_launcher: line 15: kill: (6062) - No such process
(6042) exiting
ok: run: redis: (pid 6038) 1s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 6038) 9s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 17s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 6038) 24s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 32s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 6038) 39s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 47s
ok: run: postgres: (pid 6134) 0s
supervisor pid: 6126 unicorn pid: 6136
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:104:in `block in reload': directory for pid=/var/www/discourse/tmp/pids/unicorn.pid not writable (ArgumentError)

            raise ArgumentError, "directory for #{var}=#{path} not writable"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `each'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `reload'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
config/unicorn_launcher: line 71: kill: (6136) - No such process
config/unicorn_launcher: line 15: kill: (6136) - No such process
(6126) exiting
ok: run: redis: (pid 6038) 54s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 6038) 62s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 69s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 77s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 6038) 84s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 6038) 92s
ok: run: postgres: (pid 6193) 0s
supervisor pid: 6190 unicorn pid: 6195
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:104:in `block in reload': directory for pid=/var/www/discourse/tmp/pids/unicorn.pid not writable (ArgumentError)

            raise ArgumentError, "directory for #{var}=#{path} not writable"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `each'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:100:in `reload'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/configurator.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/lib/unicorn/http_server.rb:78:in `initialize'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `new'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `load'
	from /var/www/discourse/vendor/bundle/ruby/3.2.0/bin/unicorn:25:in `<main>'
config/unicorn_launcher: line 71: kill: (6195) - No such process
config/unicorn_launcher: line 15: kill: (6195) - No such process
(6190) exiting
ok: run: redis: (pid 6038) 94s

这看起来像是文件夹权限问题。这有点奇怪,因为该文件夹位于容器文件系统内部,而不是从主机挂载的。

您可以尝试进入正在运行的容器并手动调整文件夹权限。如果您需要这方面的帮助,能否请您分享以下命令的输出:

docker exec -it app ls -lah /var/www/discourse/tmp/pids
2 个赞
docker exec -it app chown discourse.www-data /var/www/discourse/tmp/pids
docker exec -it app chmod g+w /var/www/discourse/tmp/pids
./launcher rebuild app

我又要从头开始安装了,这次我打算多留意一下应用构建的日志消息。

我看到了这些:

153:C 16 Aug 2023 20:24:11.676 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
153:C 16 Aug 2023 20:24:11.676 # Redis version=7.0.7, bits=64, commit=00000000, modified=0, pid=153, just started
153:C 16 Aug 2023 20:24:11.676 # Configuration loaded
153:M 16 Aug 2023 20:24:11.677 * monotonic clock: POSIX clock_gettime
153:M 16 Aug 2023 20:24:11.677 # Warning: Could not create server TCP listening socket *:6379: bind: Address already in use
153:M 16 Aug 2023 20:24:11.678 # Failed listening on port 6379 (TCP), aborting.

还有这个:

I, [2023-08-16T20:24:26.172936 #1]  INFO -- : cd /var/www/discourse & su discourse -c 'yarn install --frozen-lockfile & yarn cache clean'
warning “ @glint/environment-ember-loose@1.0.2” has unmet peer dependency “@glimmer/component@^1.1.2”。
warning “ @glint/environment-ember-template-imports@1.0.2” has unmet peer dependency “ember-template-imports@^3.0.0”。
warning “ @mixer/parallel-prettier@2.0.3” has unmet peer dependency “prettier@^2.0.0”。
warning Resolution field “babel-plugin-ember-template-compilation@2.0.0” is incompatible with requested version “babel-plugin-ember-template-compilation@^2.0.1”
warning Resolution field “unset-value@2.0.1” is incompatible with requested version “unset-value@^1.0.0”
warning “ babel-plugin-debug-macros@0.4.0-pre1” has unmet peer dependency “@babel/core@^7.0.0”。
warning “workspace-aggregator-d7aa52aa-3a92-43f5-97ca-2c6c21fe43f0 > discourse > @uppy/aws-s3@3.0.6” has incorrect peer dependency “@uppy/core@^3.1.2”。
warning “workspace-aggregator-d7aa52aa-3a92-43f5-97ca-2c6c21fe43f0 > discourse > @uppy/aws-s3-multipart@3.1.3” has incorrect peer dependency “@uppy/core@^3.1.2”。
warning “workspace-aggregator-d7aa52aa-3a92-43f5-97ca-2c6c21fe43f0 > discourse > @uppy/xhr-upload@3.1.1” has incorrect peer dependency “@uppy/core@^3.1.2”。
warning “workspace-aggregator-d7aa52aa-3a92-43f5-97ca-2c6c21fe43f0 > discourse > @uppy/aws-s3 > @uppy/xhr-upload@3.3.0” has incorrect peer dependency “@uppy/core@^3.2.1”。

(等它构建完成,我会尝试手动更改权限。)

Chowning + chmodding 之前:

root@ubuntu-app:/var/www/discourse# ls -lah /var/www/discourse/tmp/pids
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 16 20:47 .
drwxr-xr-x 6 root root 4.0K Aug 16 20:53 ..

之后:

root@ubuntu-app:/var/www/discourse# ls -lah /var/www/discourse/tmp/pids
total 16K
drwxrwxr-x 1 discourse www-data 4.0K Aug 16 20:58 .
drwxr-xr-x 1 root      root     4.0K Aug 16 20:53 ..
-rw-r--r-- 1 discourse www-data    5 Aug 16 20:58 unicorn.pid

现在 ./launcher logs app 的末尾看起来是这样的:

ok: run: redis: (pid 5790) 184s
ok: run: postgres: (pid 6154) 0s
supervisor pid: 6155 unicorn pid: 6159
config/unicorn_launcher: line 71: kill: (6159) - No such process
config/unicorn_launcher: line 15: kill: (6159) - No such process
(6155) exiting
ok: run: redis: (pid 5790) 188s
ok: run: postgres: (pid 6176) 0s
supervisor pid: 6177 unicorn pid: 6181
config/unicorn_launcher: line 71: kill: (6181) - No such process
config/unicorn_launcher: line 15: kill: (6181) - No such process
(6177) exiting
ok: run: redis: (pid 5790) 192s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 5790) 200s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 5790) 208s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 5790) 215s
timeout: down: postgres: 0s, normally up, want up
ok: run: redis: (pid 5790) 223s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 5790) 230s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 5790) 238s
ok: run: postgres: (pid 6264) 0s
supervisor pid: 6260 unicorn pid: 6266
config/unicorn_launcher: line 71: kill: (6266) - No such process
config/unicorn_launcher: line 15: kill: (6266) - No such process
(6260) exiting
ok: run: redis: (pid 5790) 244s
ok: run: postgres: (pid 6283) 0s
supervisor pid: 6284 unicorn pid: 6288

我的浏览器报告了一个关于该站点的 HTTPS 问题,当我选择绕过该问题的“危险”选项时,我看到了 nginx 的“网关错误”页面。

我遇到了与当前 git 相同的问题。

chownchmod 之后重建容器将撤销它们的效果。

我遇到了同样的问题。上次 Discourse 出现故障是因为插件存在未被发现的问题。我正在使用这些插件:

          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/tfpk/discourse-reveal-anonymous.git
          - git clone https://github.com/discourse/discourse-push-notifications.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-math.git

我们可以交流一下吗?这些插件目前是否存在任何已知问题?

这里有更多信息。在 gunicorn stderr 中,我看到:

/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in new_client': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (ActiveRecord::ConnectionNotEstablished)
	Is the server running locally and accepting connections on that socket?

在 PG 日志中,我看到:

2023-08-21 19:24:00.721 UTC [1681] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-08-21 19:24:00.728 UTC [1681] LOG:  could not open configuration file "/etc/postgresql/13/main/pg_hba.conf": Permission denied
2023-08-21 19:24:00.728 UTC [1681] FATAL:  could not load pg_hba.conf
2023-08-21 19:24:00.741 UTC [1681] LOG:  database system is shut down

此外:

# ls -l /etc/postgresql/13/main/pg_hba.conf
-rw-r----- 1 root root 4846 Aug 21 19:05 /etc/postgresql/13/main/pg_hba.conf

Postgres 在容器内是以什么用户运行的?根据上述权限,它必须是 root 或属于 root 组的某人。

好的,我执行了 chmod o+r /etc/postgresql/13/main/pg_hba.conf,现在容器又启动了。

这一切有点令人担忧——为什么推荐的安装方法不能开箱即用?我的插件状态目前包括上面列出的插件,除了数据浏览器,我禁用了它,因为它上次导致了失败。

交叉链接到

其中报告了类似的症状。

更新:我已按照链接帖子中的描述,在 app.yml 文件的 cmd 部分更改了 git 命令以使用 sudo

我将此故障声明为间歇性的。在 3 次尝试中(每次尝试之间我都完全清除了 shared 目录),有一次成功,两次失败。当它失败时,手动修复三个有问题的权限然后重新启动容器,似乎就能使系统正常工作。更好的日志记录和更好的自检功能将有助于检测容器启动失败。

更改 /var/www/discourse/tmp/pids/etc/postgre/13/main/pg_hba.conf 的权限对我不起作用。

我在重建之前更改了我的插件列表,但即使在恢复插件列表后,我仍然收到相同的 ArgumentError。我们确定是插件列表导致的问题吗?

启动容器后,我看到文件被写入 pids 目录。我的启动器日志在此之后停止

ok: down: unicorn: 0s, normally up
run-parts: executing /etc/runit/3.d/10-redis
ok: down: redis: 0s, normally up
run-parts: executing /etc/runit/3.d/99-postgres
run-parts: executing /etc/runit/1.d/00-ensure-links
run-parts: executing /etc/runit/1.d/00-fix-var-logs
run-parts: executing /etc/runit/1.d/01-cleanup-web-pids
run-parts: executing /etc/runit/1.d/anacron
run-parts: executing /etc/runit/1.d/cleanup-pids
Cleaning stale PID files
run-parts: executing /etc/runit/1.d/copy-env
Started runsvdir, PID is 35
ok: run: redis: (pid 52) 0s
ok: run: postgres: (pid 55) 0s
supervisor pid: 42 unicorn pid: 75

还有什么我可以查看的吗?

我在这个主题中描述了同样的问题。今天尝试在新的服务器上安装 discourse,但由于缺少写入权限而失败。

使用 chown/chmod 的“修复”对我不起作用,权限在 ./launcher rebuild app 时被重置。

您设法在新安装上重现了这个问题吗?这非常有用的信息,因为我无法通过更新现有安装来重现它。

是的,我尝试按照指南安装 Discourse,以为自己疯了,因为一切“似乎”都正常工作,但我只收到“502”错误。

我尝试在不重建的情况下更改容器内的权限。现在我得到这个:

ok: run: redis: (pid 50) 4677s
ok: run: postgres: (pid 12224) 0s
supervisor pid: 12215 unicorn pid: 12226
config/unicorn_launcher: line 71: kill: (12226) - No such process
config/unicorn_launcher: line 15: kill: (12226) - No such process
(12215) exiting
ok: run: redis: (pid 50) 4686s
ok: run: postgres: (pid 12249) 0s
supervisor pid: 12240 unicorn pid: 12251
config/unicorn_launcher: line 71: kill: (12251) - No such process
config/unicorn_launcher: line 15: kill: (12251) - No such process
(12240) exiting
ok: run: redis: (pid 50) 4695s
timeout: down: postgres: 1s, normally up, want up
ok: run: redis: (pid 50) 4703s
ok: run: postgres: (pid 12279) 0s
supervisor pid: 12275 unicorn pid: 12281

我还有第二台服务器,设置与这台完全相同,运行已超过一年。那台服务器运行正常,停止容器、执行 git pull、重建和启动也同样有效。

1 个赞

由于我在这个主题中没有看到,因此将此添加为数据点。

您是否在 unicorn 日志中看到 fatal: detected dubious ownership... 消息?我收到了这条消息。

/var/www/discourse 添加为 gitconfig 中的 safe.directory 对我的安装无效。

所以我刚刚设置了一个全新的 Ubuntu 22.04 的 droplet,运行了安装指南,它运行得很好。在新旧安装中都无法重现此问题。

你使用的是什么发行版?

全新的安装中没有这个:

root@test-install:/var/discourse# cat /var/discourse/shared/standalone/log/rails/unicorn.std*
I, [2023-08-22T17:16:33.594602 #2982]  INFO -- : Refreshing Gem list
I, [2023-08-22T17:16:38.624384 #2982]  INFO -- : listening on addr=127.0.0.1:3000 fd=10
I, [2023-08-22T17:16:43.003213 #2982]  INFO -- : starting 1 supervised sidekiqs
I, [2023-08-22T17:16:47.070059 #2982]  INFO -- : master process ready
I, [2023-08-22T17:16:50.490722 #3068]  INFO -- : worker=0 ready
I, [2023-08-22T17:16:52.394685 #3077]  INFO -- : worker=1 ready
I, [2023-08-22T17:16:53.139229 #3085]  INFO -- : worker=2 ready
I, [2023-08-22T17:16:53.518292 #3097]  INFO -- : worker=3 ready
Loading Sidekiq in process id 3059
2 个赞