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를 사용하지 않는다는 사실.
  • 이메일 설정도 함께 변경했다는 사실(이것이 영향을 미칠 것 같지는 않습니다).

도움 부탁드립니다. 감사합니다.

다른 서브도메인을 사용하세요. 더 이상 http에서는 discourse가 작동하지 않는 것 같습니다.

: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

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

다음에 무엇을 해야 할지 확신이 서지 않습니다.

확인차, Let’s Encrypt 쿼터 제한이 만료되었으므로 위의 패치를 적용하지 않고 시도해 보았습니다. 결과는 다음과 같습니다:

[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
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".

(빌드가 끝나면 수동으로 권한을 변경해 보겠습니다.)

chown + chmod를 적용하기 전:

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의 “bad gateway” 페이지가 표시됩니다.

현재 git에서도 같은 문제를 겪고 있습니다.

chown과 chmod 후 컨테이너를 다시 빌드하면 그 효과가 사라집니다.

저도 같은 문제를 겪고 있습니다. 마지막으로 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를 실행한 후 컨테이너가 다시 정상 작동합니다.

이 모든 상황이 다소 우려스럽습니다. 권장 설치 방법이 왜 처음부터 제대로 작동하지 않는 걸까요? 현재 제 플러그인 상태에는 위에서 언급한 것들이 모두 포함되어 있으며, data explorer는 지난번에 실패를 유발했기 때문에 비활성화했습니다.

유사한 증상을 보고한 아래 링크를 교차 참조합니다.

업데이트: 링크된 게시물에서 설명한 대로 app.yml 파일의 cmd 섹션에서 git 명령을 sudo를 사용하도록 변경했습니다.

이 실패가 간헐적이라고 판단합니다. 3번의 시도(시도 사이마다 shared 디렉토리를 완전히 삭제) 중 1번은 성공하고 2번은 실패했습니다. 실패할 때, 문제의 세 가지 권한을 수동으로 수정한 후 컨테이너를 다시 시작하면 정상적으로 작동하는 시스템으로 보입니다. 실패한 컨테이너 부트스트랩을 감지하기 위해 더 나은 로깅과 자체 테스트가 있으면 좋겠습니다.

/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

이것과 정확히 동일한 구성으로 설정된 두 번째 서버가 1년 이상 정상적으로 작동하고 있습니다. 그 서버에서는 컨테이너를 중지하고, git pull을 수행한 후, 다시 빌드하고 시작하는 과정도 모두 정상적으로 작동했습니다.

이 주제에서 해당 내용을 찾지 못해서 참고 자료로 추가합니다.

unicorn 로그에서 fatal: detected dubious ownership... 메시지가 표시되나요? 제 경우에도 이 메시지가 표시됩니다.

/var/www/discourse를 safe.directory로 gitconfig에 추가했지만 제 설치 환경에서는 효과가 없습니다.

그래서 방금 만든全新的 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