ArgumentError: pid=/.../unicorn.pid 디렉토리에 쓰기 권한이 없습니다

추가 정보를 공유합니다. 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번은 실패했습니다. 실패할 때, 문제의 세 가지 권한을 수동으로 수정한 후 컨테이너를 다시 시작하면 정상적으로 작동하는 시스템으로 보입니다. 실패한 컨테이너 부트스트랩을 감지하기 위해 더 나은 로깅과 자체 테스트가 있으면 좋겠습니다.